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


PHP Session::set方法代碼示例

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


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

示例1: width

 /**
  * Set page width
  *
  * @param  string  $width
  */
 public function width($width)
 {
     $this->session->set('page_width', $width == 'wide' ? 'liquid' : 'fixed');
     if (request::is_ajax()) {
         return;
     }
     url::back();
 }
開發者ID:anqqa,項目名稱:Anqh,代碼行數:13,代碼來源:set.php

示例2: testFlush

 public function testFlush()
 {
     $this->target->set('bindable.dummy.xyzzy', 'hogefuga');
     $this->target->bind($this->bindable);
     \Phake::when($this->bindable)->getSessionContent()->thenReturn(array('hoge' => 'hogehoge', 'xyzzy' => 'piyopiyo'));
     $this->target->flush();
     $this->assertEquals(array('HOGE' => 1, 'FUGA' => 2, 'PIYO' => array('FIZZ' => 'BUZZ'), 'bindable' => array('dummy' => array('hoge' => 'hogehoge', 'xyzzy' => 'piyopiyo'))), $_SESSION);
 }
開發者ID:aainc,項目名稱:Hoimi,代碼行數:8,代碼來源:SessionTest.php

示例3: autologin

 /**
  * Automatic login user.
  *
  * @return boolean
  */
 public function autologin()
 {
     $this->session = getSession();
     $user_id = $this->authenticate();
     if ($user_id === false) {
         return false;
     }
     $this->session->set("user_id", $user_id);
     return true;
 }
開發者ID:GameCrusherTechnology,項目名稱:HeroTowerServer,代碼行數:15,代碼來源:Auth.class.php

示例4: setUser

 public static function setUser(User $user)
 {
     self::$currentUser = $user;
     $app = ActiveRecordModel::getApplication();
     $app->processRuntimePlugins('session/before-login');
     $session = new Session();
     $session->set('User', $user->getID());
     $session->set('UserGroup', $user->userGroup->get() ? $user->userGroup->get()->getID() : 0);
     if ($app->getSessionHandler()) {
         $app->getSessionHandler()->setUser($user);
     }
     $app->processRuntimePlugins('session/login');
 }
開發者ID:saiber,項目名稱:www,代碼行數:13,代碼來源:SessionUser.php

示例5: redirectToChangePassword

    /**
     * Redirect the user to the change password form.
     *
     * @return SS_HTTPResponse
     */
    protected function redirectToChangePassword()
    {
        // Since this form is loaded via an iframe, this redirect must be performed via javascript
        $changePasswordForm = new ChangePasswordForm($this->controller, 'ChangePasswordForm');
        $changePasswordForm->sessionMessage(_t('Member.PASSWORDEXPIRED', 'Your password has expired. Please choose a new one.'), 'good');
        // Get redirect url
        $changePasswordURL = $this->getExternalLink('changepassword');
        if ($backURL = $this->controller->getRequest()->requestVar('BackURL')) {
            Session::set('BackURL', $backURL);
            $changePasswordURL = Controller::join_links($changePasswordURL, '?BackURL=' . urlencode($backURL));
        }
        $changePasswordURLATT = Convert::raw2att($changePasswordURL);
        $changePasswordURLJS = Convert::raw2js($changePasswordURL);
        $message = _t('CMSMemberLoginForm.PASSWORDEXPIRED', '<p>Your password has expired. <a target="_top" href="{link}">Please choose a new one.</a></p>', 'Message displayed to user if their session cannot be restored', array('link' => $changePasswordURLATT));
        // Redirect to change password page
        $this->controller->getResponse()->setStatusCode(200);
        $this->controller->getResponse()->setBody(<<<PHP
<!DOCTYPE html>
<html><body>
{$message}
<script type="application/javascript">
setTimeout(function(){top.location.href = "{$changePasswordURLJS}";}, 0);
</script>
</body></html>
PHP
);
        return $this->controller->getResponse();
    }
開發者ID:assertchris,項目名稱:silverstripe-framework,代碼行數:33,代碼來源:CMSMemberLoginForm.php

示例6: login

 public function login()
 {
     if (Session::get('isLoggedIn')) {
         Messages::addMessage("info", "You are already logged in.");
         return;
     } else {
         $response = array();
         // params have to be there
         $user_name = $this->params->getValue('user_name');
         $user_password = $this->params->getValue('password');
         if ($user_name != null && $user_password != null) {
             // check if user name and password are correct
             $usr = $this->userManager->findUser($user_name, $user_password);
             if ($usr != null) {
                 // log user in
                 Session::set("user_name", $usr['user_name']);
                 Session::set("id", $usr['ID']);
                 Session::set("isLoggedIn", true);
                 return $usr;
             } else {
                 Messages::addMessage("info", "Log in user and/or password incorrect.");
                 return null;
             }
         } else {
             Messages::addMessage("warning", "'user_name' and/or 'password' parameters missing.");
             return null;
         }
     }
 }
開發者ID:AlinaQ,項目名稱:3D_products,代碼行數:29,代碼來源:UserLoginAction.php

示例7: register

 public function register()
 {
     $response = array();
     // params have to be there
     $usr = $this->params->getValue('username');
     $pwd = $this->params->getValue('password');
     $encrypt = md5($pwd);
     $fname = $this->params->getValue('firstname');
     $lname = $this->params->getValue('lastname');
     $email = $this->params->getValue('email');
     echo $usr . " " . $pwd . " " . $fname . " " . $lname . " " . $email . " " . $encrypt;
     if ($usr != null && $pwd != null && $fname != null && $lname != null && $email != null) {
         // check if user name and password are correct
         $user = $this->userManager->addUser($fname, $lname, $usr, $encrypt, $email);
         if ($user != null) {
             // log user in
             Session::set("username", $user['username']);
             Session::set("id", $user['ID']);
             Session::set("isLoggedIn", true);
             return $user;
             return $user['ID'];
             return $encrypt;
             //return $response;
         } else {
             Messages::addMessage("warning", "'user_name' and/or 'password' parameters missing.");
             return null;
             return $usr;
         }
     }
 }
開發者ID:VHughes,項目名稱:Flower2Go,代碼行數:30,代碼來源:NewUserAction.php

示例8: loginAction

 public function loginAction()
 {
     $userInfo = Session::get('user');
     if ($userInfo['login'] == true && $userInfo['time'] + TIME_LOGIN >= time()) {
         URL::redirect('default', 'user', 'index');
     }
     $this->_view->_title = 'Login';
     if (@$this->_arrParam['form']['token'] > 0) {
         $validate = new Validate($this->_arrParam['form']);
         $email = $this->_arrParam['form']['email'];
         $password = md5($this->_arrParam['form']['password']);
         $query = "SELECT `id` FROM `user` WHERE `email` = '{$email}' AND `password` = '{$password}'";
         $validate->addRule('email', 'existRecord', array('database' => $this->_model, 'query' => $query));
         $validate->run();
         if ($validate->isValid() == true) {
             $infoUser = $this->_model->infoItem($this->_arrParam);
             $arraySession = array('login' => true, 'info' => $infoUser, 'time' => time(), 'group_acp' => $infoUser['group_acp']);
             Session::set('user', $arraySession);
             URL::redirect('default', 'user', 'index');
         } else {
             $this->_view->errors = $validate->showErrorsPublic();
         }
     }
     $this->_view->render('index/login');
 }
開發者ID:shimia90,項目名稱:PHP-Training,代碼行數:25,代碼來源:IndexController.php

示例9: forgotpwd

 /**
  * Forgot password
  */
 private function forgotpwd()
 {
     if (isset($_POST['forgotpwd'])) {
         $email = $_POST['email'];
         if (!Validate::len($email)) {
             $error = 'Email character count must be between 4 and 64';
         } elseif (!Validate::email($email)) {
             $error = 'Please enter a valid email';
         }
         if (!$error) {
             $user = User::where('email', $email)->select('id')->findOne();
             if (!$user) {
                 $error = 'Email address not found';
             }
         }
         if ($error) {
             View::error('user/forgotpwd', $error);
         }
         // Makes an internal session
         $pwd = Session::set('pwd', $user->id, 0);
         View::set('session_pwd', $pwd);
         Base::sendMail($email, 'forgotpwd');
         Base::redirect('', 'Go to your email and follow the instructions');
     } elseif (isset($_GET['pwd'])) {
     }
 }
開發者ID:nytr0gen,項目名稱:plur-music-explorer,代碼行數:29,代碼來源:user.php

示例10: index

 /**
  * Default method
  * @return [type] [description]
  */
 public function index()
 {
     if (Session::get('logined') !== null) {
         if (Session::get('logined')) {
             $this->getUserLogin();
             exit;
         }
     }
     $auth = new Authenticate();
     if (isset($_POST['user_id']) && isset($_POST['id_token'])) {
         $user_id = $_POST['user_id'];
         $id_token = $_POST['id_token'];
         if ($auth->checkLogin($user_id, $id_token)) {
             Session::init();
             Session::set('id_token', $id_token);
             Session::set('user_id', $user_id);
             Session::set('logined', true);
             echo json_encode('success');
             exit;
         } else {
             echo json_encode('need login with google ID');
             exit;
         }
     } else {
         echo json_encode('need login with google ID');
         exit;
     }
 }
開發者ID:uethackathon,項目名稱:uethackathon2015_team5,代碼行數:32,代碼來源:login.php

示例11: Register

 /**
  * @param $data
  * @param $form
  * @return bool|SS_HTTPResponse
  */
 function Register($data, $form)
 {
     // Set session array individually as setting the password breaks the form.
     $sessionArray = array('Email' => $data['Email']);
     // Check for existing member email address
     if ($existingUser = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "'")) {
         $form->AddErrorMessage('Email', _t('RegistrationPage.EmailValidationText', 'Sorry, that email address already exists. Please choose another.'), 'validation');
         Session::set('FormInfo.Form_RegistrationForm.data', $sessionArray);
         return $this->redirectBack();
     }
     // Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     $Member->login();
     // Find or create the 'user' group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
         $userGroup = new Group();
         $userGroup->Code = 'users';
         $userGroup->Title = 'Users';
         $userGroup->Write();
         $userGroup->Members()->add($Member);
     }
     // Add member to user group
     $userGroup->Members()->add($Member);
     // Get profile page otherwise display warning.
     if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
         $name = $data['FirstName'] ?: ($name = $data['Email']);
         $this->setFlash(_t('RegistrationPage.RegisteredSuccessText', 'Welcome ' . $name . ', your account has been created!'), 'success');
         return $this->redirect($ProfilePage->Link());
     } else {
         $this->setFlash(_t('RegistrationPage.RegisteredWarningText', 'Please add a "Edit Profile Page" in your SiteTree to enable profile editing'), 'warning');
         return $this->redirect(Director::absoluteBaseURL());
     }
 }
開發者ID:ormandroid,項目名稱:ss_boilerplate,代碼行數:40,代碼來源:RegistrationPage.php

示例12: logout

 /**
  * logout
  *
  * @param void
  * @return void
  */
 public static function logout()
 {
     Load::lib('auth');
     Load::lib('session');
     Session::set(SESSION_KEY, false);
     Auth::destroy_identity();
 }
開發者ID:KumbiaPHP,項目名稱:KuBlog,代碼行數:13,代碼來源:SdAuth.php

示例13: registerAction

 /**
  * 確認注冊【設定密碼】
  * @method registerAction
  * @return [type]         [description]
  * @author NewFuture
  */
 public function registerAction()
 {
     $msg = '信息注冊失敗!';
     if ($regInfo = Session::get('reg')) {
         Session::del('reg');
         if (Input::post('password', $password, 'trim') === false) {
             /*密碼未md5*/
             $this->error('密碼錯誤', '/');
         } elseif (!$password) {
             /*未設置密碼*/
             $password = $regInfo['password'];
         }
         $regInfo['password'] = Encrypt::encryptPwd($password, $regInfo['number']);
         if ($id = UserModel::insert($regInfo)) {
             /*注冊成功*/
             $regInfo['id'] = $id;
             $token = Auth::token($regInfo);
             Cookie::set('token', [$id => $token]);
             unset($regInfo['password']);
             Session::set('user', $regInfo);
             $msg = '信息注冊成功!';
         }
     }
     $this->jump('/', $msg);
 }
開發者ID:derek-chow,項目名稱:YunYinService,代碼行數:31,代碼來源:Api.php

示例14: ingresar

 public function ingresar()
 {
     try {
         $user = $this->getTexto('txtLogin');
         $pass = $this->getTexto('txtContraseña');
         if (!empty($user) && !empty($pass)) {
             $objUser = $this->_login->getUsuario($user);
             if ($objUser) {
                 if (strtolower($objUser[0]->getUsername()) == $user && $objUser[0]->getPassword() == crypt($pass, 'SMSYS')) {
                     Session::set('SESS_USER', $objUser[0]->getUsername());
                     if (Session::get('SESS_ERRLOGIN') != null) {
                         Session::destroy('SESS_ERRLOGIN');
                     }
                     header('Location: ' . BASE_URL . 'sistema');
                 } else {
                     //Session::set('SESS_ERRLOGIN',$user.' '.$pass);
                     Session::set('SESS_ERRLOGIN', 'Usuario o contraseña incorrectos');
                     header('Location: ' . BASE_URL . 'login');
                 }
             } else {
                 //Session::set('SESS_ERRLOGIN',$user.' '.$pass);
                 Session::set('SESS_ERRLOGIN', 'No existe ese usuario registrado');
                 header('Location: ' . BASE_URL . 'login');
             }
         }
     } catch (Exception $ex) {
         echo $ex->getMessage();
     }
 }
開發者ID:spellbring,項目名稱:MVC,代碼行數:29,代碼來源:loginController.php

示例15: before

 public function before()
 {
     parent::before();
     $flag = $this->getNotOpenidAllowed();
     if ($flag) {
         return;
     }
     if (!\Session::get('wechat', false) && !\Input::get('openid', false)) {
         //獲取到openid之後跳轉的參數列表
         //$params = \handler\mp\UrlTool::createLinkstring(\Input::get());
         //本站域名
         $baseUrl = \Config::get('base_url');
         $url = $baseUrl . \Input::server('REQUEST_URI');
         $toUrl = urlencode($url);
         $callback = "{$baseUrl}wxapi/oauth2_callback?to_url={$toUrl}";
         $account = \Session::get('WXAccount', \Model_WXAccount::find(1));
         $url = \handler\mp\Tool::createOauthUrlForCode($account->app_id, $callback);
         \Response::redirect($url);
     } else {
         if (!\Session::get('wechat', false)) {
             $wxopenid = \Model_WechatOpenid::query()->where(['openid' => \Input::get('openid')])->get_one();
             if (!$wxopenid) {
                 \Session::set_flash('msg', ['status' => 'err', 'msg' => '未找到您的微信信息,無法確認您的身份! 係統無法為您提供服務!', 'title' => '拒絕服務']);
                 return $this->show_mesage();
             }
             \Session::set('wechat', $wxopenid->wechat);
             \Session::set('OpenID', $wxopenid);
             \Auth::force_login($wxopenid->wechat->user_id);
         } else {
             if (!\Auth::check() && \Session::get('wechat')->user_id) {
                 \Auth::force_login(\Session::get('wechat')->user_id);
             }
         }
     }
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:35,代碼來源:wxcontroller.php


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