当前位置: 首页>>代码示例>>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;未经允许,请勿转载。