public function post() { //do form validation, what does that mean? try { //This line is perhaps the one I'm least confident in. //We need this object. I'm not sure exactly the best way to build it, and how //much validation happens when you build it. In the end, it just needs to //implement the right interface for the operation we're performing later. $reviewAnswers = new PerformanceReviewAnswersRequest($this->reviewId, $_POST['questions']); } catch (InvalidArgumentException $exception) { //invalid data posted. Session::message("I'm sorry, you did it wrong."); $this->redirect("review.php?id=" . $this->reviewId); } $this->getPerformanceReviewService()->answerReviewQuestions($reviewAnswers); if ($_POST['action'] == 'submit') { $this->getPerformanceReviewService()->submitPerformanceReview($this->reviewId, new DateTime(null, new DateTimeZone('UTC'))); } $this->redirect("review.php?id=" . $this->reviewId); }
$_SESSION['message'] = $msg; } else { //then this is "get message" return $this->message; } } private function check_login() { if (isset($_SESSION['user_id'])) { $this->user_id = $SESSION['user_id']; $this->logged_in = true; } else { unset($this->user_id); $this->logged_in = false; } } private function check_message() { //Is there a message stored in the session? if (isset($_SESSION['message'])) { //Add it as an attribute and erase the stored version $this->message = $_SESSION['message']; unset($_SESSION['message']); } else { $this->message = ""; } } } $session = new Session(); $message = $session->message();
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // Product::find($id)->delete(); Session::flash('status', true); Session::message('status', array('Đã xóa')); return Redirect::route('admin.product.index'); }
{ unset($this->user_id); $_SESSION['user_id'] = null; unset($_SESSION['user_id']); unset($this->sh_id); $_SESSION['sh_id'] = null; unset($_SESSION['sh_id']); $this->logged_in = false; $this->found = false; } public function check_message() { if (isset($_SESSION['message'])) { $this->message = $_SESSION['message']; unset($_SESSION['message']); } else { $this->message = ""; } } public function message($msg = "") { if (!empty($msg)) { $_SESSION['message'] = $msg; } else { return $this->message; } } } $session = new Session(); $message_display = $session->message();
return false; } } else { if ($this->prefix) { return $_SESSION[$this->prefix]; } else { return $_SESSION; } } } public function SetSessId($sessId = false) { if ($sessId) { session_id($sessId); } } public static function getSession() { $session =& $GLOBALS['_S']; if ($session instanceof Session) { return $session; } else { $session = new Session(); $GLOBALS['_S'] = $session; return $session; } } } $_S = new Session(); $message = $_S->message();
<?php require_once 'lib/init.php'; if (!isset($session)) { $session = new Session(); $session->message(); } if ($session->isLoggedIn()) { redirect_to("app/index.php"); } if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; if (empty($username) || empty($password)) { $err = "Username or password cannot be empty"; } else { $found = User::authenticate($username, $password); if ($found) { $session->login($found, $ac); $session->message("Welcome {$username}"); $session->sessionVar("user", "You are logged in as {$username}"); redirect_to("app/index.php"); } else { $err = "Username and/or password is incorrect. Please try again"; } } } else { // Form not submitted $msg = ""; } ?>
//$employee->active_user(); $employee->approved_account(); $user_found = Employee::find_by_id($user_id); $access = "User"; //session_start(); //$_SESSION['user_id'] = $user_id; //$_SESSION['username'] = $employee->username ; //$_SESSION['access_level'] = $access; //die; global $session; $session = new Session(); $session->login($user_found, $access); } else { $message = "<div class='error'> \r\n\t\t\t\t\t\t\t" . get_lang('following_errors') . "\r\n\t\t\t\t\t\t<ul> <li />"; $message .= join(" <li /> ", $employee->errors); $message .= " </ul> \r\n\t\t\t\t\t\t\t</div>"; $session->message($message); $smarty->assign('message', $message); redirect_to(BASE_URL . "login/"); exit; } //echo $message; //die("error".$message); redirect_to(BASE_URL . "account/"); exit; } catch (Exception $o) { //d($o); } } redirect_to(BASE_URL . "login/"); exit;