當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session::add方法代碼示例

本文整理匯總了PHP中Session::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::add方法的具體用法?PHP Session::add怎麽用?PHP Session::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Session的用法示例。


在下文中一共展示了Session::add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

 public function indexAction()
 {
     $session = new Session();
     $session->add('name', 'php');
     $session->add('type', 'web');
     var_dump($_SESSION);
     $session->remove('name');
     var_dump($_SESSION);
     // 移去所有session變量
     $session->clear();
     // 移去存儲在服務器端的數據
     $session->destroy();
     //        $session->close();
     var_dump($_SESSION);
 }
開發者ID:tomorrowdemo,項目名稱:haojiaolexue,代碼行數:15,代碼來源:Session.php

示例2: validar

 /**
  * Método encargado de validar datos
  * @param  Array $array Datos a validar
  * @return Boolean      true = si los datos son validos, false = si son invalidos
  */
 public static function validar($array)
 {
     // Validación de la clave
     if (isset($array['clave'])) {
         if (($erro = Validaciones::validarPassLogin($array["clave"])) !== true) {
             Session::addArray('feedback_negative', $erro);
         }
     } else {
         Session::add('feedback_negative', 'No se ha indicado la clave');
     }
     // Validación del email
     if (isset($array['email'])) {
         if (($erro = Validaciones::validarEmail($array["email"])) !== true) {
             Session::addArray('feedback_negative', $erro);
         }
     } else {
         Session::add('feedback_negative', 'No se ha indicado el email');
     }
     // Si hay errores devolvemos false
     if (Session::get('feedback_negative')) {
         return false;
     }
     // Si no hay errores devolvemos true
     return true;
 }
開發者ID:khru,項目名稱:MVC-oferta,代碼行數:30,代碼來源:LoginModel.php

示例3: login

 public static function login()
 {
     // validate the length
     if (strlen(Request::post('login_name')) < 2 || strlen(Request::post('login_name')) > 20 || strlen(Request::post('login_password')) < 8 || strlen(Request::post('login_password')) > 255) {
         // give the same feedback that's on wrong user name to not give out any data
         Session::add('feedback_negative', 'Error. Username or password wrong.');
         return false;
     }
     // get user details
     $user = self::getUserData('user_name', Request::post('login_name'));
     // if there's no user with given name
     if (!$user) {
         Session::add('feedback_negative', 'Error. Username or password wrong.');
         return false;
     }
     // check if password ok
     if (!password_verify(Request::post('login_password'), $user->user_password)) {
         // give the same feedback that's on wrong user name to not give out any data
         Session::add('feedback_negative', 'Error. Username or password wrong.');
         return false;
     }
     // set session variables
     Session::set('user_id', $user->user_id);
     Session::set('user_name', $user->user_name);
     Session::set('user_permissions', $user->user_permissions);
     // set user as logged-in
     Session::set('user_logged_in', true);
     return true;
 }
開發者ID:shx13,項目名稱:skeletor,代碼行數:29,代碼來源:LoginModel.php

示例4: edit

 public static function edit($datos)
 {
     $conn = Database::getInstance()->getDatabase();
     $errores_validacion = false;
     if (empty($datos['id_pregunta'])) {
         Session::add('feedback_negative', 'No he recibido la pregunta');
         $errores_validacion = true;
     }
     if (empty($datos['asunto'])) {
         Session::add('feedback_negative', "No he recibido el asunto de la pregunta");
         $errores_validacion = true;
     }
     if (empty($datos['cuerpo'])) {
         Session::add('feedback_negative', "No he recibido el cuerpo de la pregunta");
         $errores_validacion = true;
     }
     if ($errores_validacion) {
         return false;
     } else {
         $ssql = "UPDATE pregunta SET asunto=:asunto, cuerpo=:cuerpo WHERE id_pregunta=:id";
         $query = $conn->prepare($ssql);
         $parameters = array(':asunto' => $datos["asunto"], ':cuerpo' => $datos["cuerpo"], ':id' => $datos["id_pregunta"]);
         $query->execute($parameters);
         $count = $query->rowCount();
         if ($count == 1) {
             Session::add('feedback_positive', 'Editado con éxito, gracias!!!');
             return true;
         }
         Session::add('feedback_positive', 'Actualizadas 0 casillas');
         return false;
     }
 }
開發者ID:cmabris,項目名稱:miniDWES,代碼行數:32,代碼來源:preguntasmodel.php

示例5: appendNotesHelpRequest

 /**
  * @function appendNotesHelpRequest
  * @public
  * @static
  * @returns {boolean} True if successful.
  * @desc Adds notes from tutor input, into a record of a help request.
  * @param {integer} $id The unique identity for the help request.
  * @param {string} $noteDD The ``quick'' option of filling in notes for a help request.
  * @param {string} $noteText The type option of filling in notes of a help request.
  * @example NONE
  */
 public static function appendNotesHelpRequest($id, $noteDD, $noteText)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $query = $database->prepare("UPDATE qscQueue.tblRequests SET notesDropDown = :note_drop_down, notesEditable = :note_text WHERE id = :id_no");
     $query->execute(array(':note_drop_down' => $noteDD, ':note_text' => $noteText, ':id_no' => $id));
     Session::add('feedback_positive', 'added the notes to a help request - success');
     return true;
 }
開發者ID:NRWB,項目名稱:TutorQueue,代碼行數:19,代碼來源:TutorModel.php

示例6: resetUserSession

 /**
  * Kicks the selected user out of the system instantly by resetting the user's session.
  * This means, the user will be "logged out".
  *
  * @param $userId
  * @return bool
  */
 private static function resetUserSession($userId)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $query = $database->prepare("UPDATE users SET session_id = :session_id  WHERE user_id = :user_id LIMIT 1");
     $query->execute(array(':session_id' => null, ':user_id' => $userId));
     if ($query->rowCount() == 1) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_USER_SUCCESSFULLY_KICKED'));
         return true;
     }
 }
開發者ID:evdevgit,項目名稱:huge,代碼行數:17,代碼來源:AdminModel.php

示例7: removePerm

 /**
  * Remove A user permission
  * @param $user_id
  * @param $removed_perm
  */
 public static function removePerm($user_id, $removed_perm)
 {
     if (self::$removePermQuery === null) {
         self::$removePermQuery = DatabaseFactory::getFactory()->getConnection()->prepare("UPDATE users SET perms = :new WHERE user_id = :user_id");
     }
     $original = UserRoleModel::getPerms($user_id);
     $being_removed = array_search($removed_perm, $original);
     unset($original[$being_removed]);
     self::$removePermQuery->execute(array(':new' => json_encode($original), ':user_id' => $user_id));
     Session::add('feedback_positive', 'Removed that permission!');
 }
開發者ID:queer1,項目名稱:PC-Track,代碼行數:16,代碼來源:UserRoleModel.php

示例8: createShort

 public static function createShort($url)
 {
     try {
         $code = ShortModel::urlToShortCode($url);
         Session::add('feedback_positive', 'SUCCESS! SHORT URL: ' . ShortModel::$shortUrlPrefix . $code);
         return true;
     } catch (Exception $e) {
         // log exception and then redirect to error page.
         Session::add('feedback_negative', 'URL SHORTENING FAILED');
         return false;
     }
 }
開發者ID:KealJones,項目名稱:Shorten,代碼行數:12,代碼來源:ShortModel.php

示例9: setRequestDetails

 /**
  * @function setRequestDetails
  * @public
  * @static
  * @returns NONE
  * @desc
  * @param {string} foo Use the 'foo' param for bar.
  * @example NONE
  */
 public static function setRequestDetails($recordID, $tableNo, $subj, $subSubj, $tutName)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     // to do = update according to the settings needed given func's params/args.
     $query = $database->prepare("UPDATE users SET user_deleted = :user_deleted  WHERE user_id = :user_id LIMIT 1");
     $query->execute(array(':user_deleted' => $delete, ':user_id' => $userId));
     // to do = determine if needed below if-statement
     if ($query->rowCount() == 1) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_SUSPENSION_DELETION_STATUS'));
         return true;
     }
 }
開發者ID:NRWB,項目名稱:TutorQueue,代碼行數:21,代碼來源:GreeterModel.php

示例10: menuIsActive

 public static function menuIsActive()
 {
     if (!Session::getNested('active_menu', 'menu_id')) {
         // destroy session
         // Session::destroy();
         //
         // create error message
         Session::add('feedback_errors', ErrorMessage::get('MENU_NOT_ACTIVE'));
         // redirect to menu selection screen
         header('Location: ' . URL_WITH_INDEX_FILE . 'menumanager/managemenus');
         exit;
     }
 }
開發者ID:puiu91,項目名稱:Learning-MVC,代碼行數:13,代碼來源:Authenticate.php

示例11: deleteNote

 /**
  * Delete a specific note
  * @param int $note_id id of the note
  * @return bool feedback (was the note deleted properly ?)
  */
 public static function deleteNote($note_id)
 {
     if (!$note_id) {
         return false;
     }
     $note = NoteQuery::create()->findPK($note_id);
     $note->delete();
     if ($note) {
         return true;
     }
     // default return
     Session::add('feedback_negative', Text::get('FEEDBACK_NOTE_DELETION_FAILED'));
     return false;
 }
開發者ID:KyleGoslan,項目名稱:Huge-Propel,代碼行數:19,代碼來源:NoteModel.php

示例12: changeUserRole

 /**
  * Upgrades / downgrades the user's account. Currently it's just the field user_account_type in the database that
  * can be 1 or 2 (maybe "basic" or "premium"). Put some more complex stuff in here, maybe a pay-process or whatever
  * you like.
  *
  * @param $type
  *
  * @return bool
  */
 public static function changeUserRole($type)
 {
     if (!$type) {
         return false;
     }
     // save new role to database
     if (self::saveRoleToDatabase($type)) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_TYPE_CHANGE_SUCCESSFUL'));
         return true;
     } else {
         Session::add('feedback_negative', Text::get('FEEDBACK_ACCOUNT_TYPE_CHANGE_FAILED'));
         return false;
     }
 }
開發者ID:KyleGoslan,項目名稱:Huge-Propel,代碼行數:23,代碼來源:UserRoleModel.php

示例13: addSelect

 public function addSelect()
 {
     if (empty($_POST['check_list_Material']) || empty($_POST['oeuvre_id'])) {
         Session::add('feedback_negative', 'Tiene que escoger una de tus obras y seleccionar algún material');
         Redirect::to('dashboard/index');
     } else {
         $arrayIdMaterial = $_POST['check_list_Material'];
         $oeuvre_id = $_POST['oeuvre_id'];
         foreach ($arrayIdMaterial as $value) {
             DashboardModel::addMaterialToOeuvre($oeuvre_id, $value);
         }
         Session::add('feedback_positive', 'Se ha añadido correctamente en tu obra señalada los materiales señalados');
         Redirect::to('dashboard/index');
     }
 }
開發者ID:PPVILLA,項目名稱:Exercise-Trabajos-Verticales,代碼行數:15,代碼來源:DashboardController.php

示例14: getPublicProfileOfUser

 /**
  * @function getPublicProfileOfUser
  * @public
  * @static
  * @returns {array} A single user profile.
  * @desc Gets a user's profile data, according to the given $user_id.
  * @param {integer} $user_id The user's id.
  * @example NONE
  */
 public static function getPublicProfileOfUser($user_id)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT user_id, user_name, user_email, user_active, user_deleted FROM users WHERE user_id = :user_id LIMIT 1";
     $query = $database->prepare($sql);
     $query->execute(array(':user_id' => $user_id));
     $user = $query->fetch();
     if ($query->rowCount() != 1) {
         Session::add('feedback_negative', Text::get('FEEDBACK_USER_DOES_NOT_EXIST'));
     }
     // all elements of array passed to Filter::XSSFilter for XSS sanitation, have a look into
     // application/core/Filter.php for more info on how to use. Removes (possibly bad) JavaScript etc from
     // the user's values
     array_walk_recursive($user, 'Filter::XSSFilter');
     return $user;
 }
開發者ID:NRWB,項目名稱:TutorQueue,代碼行數:25,代碼來源:UserModel.php

示例15: setAccountDeletionStatus

 /**
  * @function setAccountDeletionStatus
  * @public
  * @static
  * @returns NONE
  * @desc
  * @param {string} foo Use the 'foo' param for bar.
  * @example NONE
  */
 public static function setAccountDeletionStatus($softDelete, $userId)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     // FYI "on" is what a checkbox delivers by default when submitted.
     if ($softDelete == "on") {
         $delete = 1;
     } else {
         $delete = 0;
     }
     $query = $database->prepare("UPDATE users SET user_deleted = :user_deleted  WHERE user_id = :user_id LIMIT 1");
     $query->execute(array(':user_deleted' => $delete, ':user_id' => $userId));
     if ($query->rowCount() == 1) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_SUSPENSION_DELETION_STATUS'));
         return true;
     }
 }
開發者ID:NRWB,項目名稱:TutorQueue,代碼行數:25,代碼來源:AdminModel.php


注:本文中的Session::add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。