当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::Set方法代码示例

本文整理汇总了PHP中Session::Set方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::Set方法的具体用法?PHP Session::Set怎么用?PHP Session::Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session::Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Login

 /**
  * 模拟登录
  */
 public function Login($verifycode = NULL)
 {
     $data = $this->account;
     if (!is_numeric($data['username']) && !str_contains($data['username'], '@')) {
         return '用户名格式错误,请输入QQ号或QQ邮箱。';
     }
     Session::Set('qq', $data['username']);
     if (!$verifycode) {
         $ret = $this->get('http://check.ptlogin2.qq.com/check?appid=15000101&uin=' . $data['username']);
         //
         $arr = explode("'", $ret);
         $verifycode = $arr[3];
         if (strlen($verifycode) != 4) {
             return '绑定账号失败:请输入验证码';
             //'登录服务暂时不可用,请稍后再试!';
         }
     }
     $param = array('aid' => 15000101, 'fp' => 'loginerroralert', 'from_ui' => 1, 'g' => 1, 'h' => 1, 'u' => $data['username'], 'p' => $this->encpwd($data['password'], $data['username'], $verifycode), 'verifycode' => $verifycode, 'u1' => 'http://imgcache.qq.com/qzone/v5/loginsucc.html?para=izone');
     Log::customLog('qzone.txt', "GET http://ptlogin2.qq.com/login:\r\n" . print_r($param, true));
     $ret = $this->get('http://ptlogin2.qq.com/login?' . http_build_query($param));
     Log::customLog('qzone.txt', "Response:\r\n" . print_r($this->http_header, true) . print_r($ret, true));
     $arr = explode("'", $ret);
     $ret = $arr[9];
     if (start_with($ret, '登录成功')) {
         return true;
     }
     return $ret;
 }
开发者ID:z445056647,项目名称:phx-svns,代码行数:31,代码来源:QZoneSimulaAPI.class.php

示例2: Upload

 static function Upload($image)
 {
     $user = Session::Get('current_user');
     $allowedExts = array("gif", "jpeg", "jpg", "png");
     $temp = explode(".", $image["name"]);
     $extension = strtolower(end($temp));
     if (in_array($extension, $allowedExts)) {
         if ($image["error"] > 0) {
             if ($image["error"] == 1 || $image["error"] == 2) {
                 Error::Set('avatar', 'The uploaded file exceeds the upload_max_filesize directive in php.ini or in the html form.');
             }
         } else {
             if ($image["size"] >= Config::Get('avatar.maxsize')) {
                 Error::Set('avatar', 'imagemaxsize');
             } else {
                 $filename = '_' . md5($user->Get('id')) . "." . $extension;
                 $src = PLSPATH . Config::Get("avatar.upload_path") . $filename;
                 if (move_uploaded_file($image["tmp_name"], $src)) {
                     Session::Set('current_user_temp_avatar', $filename);
                     return true;
                 } else {
                     Error::Set('avatar', 'uploadfailed');
                 }
             }
         }
     } else {
         Error::Set('avatar', 'invalidimage');
     }
     return false;
 }
开发者ID:jobsbe7,项目名称:PokeDev,代码行数:30,代码来源:Avatar.php

示例3: index

 public function index()
 {
     if ($_POST) {
         $email = $this->_get("email");
         $password = $this->_get("password");
         $users = D('Users');
         $login_user = $users->GetLogin($_POST['email'], $_POST['password']);
         if (!$login_user) {
             Session::Set('error', '用户名或密码错误');
             redirect("/manage/login/index");
         } else {
             if ($login_user['is_enabled'] == 'N' && $login_user['secret']) {
                 Session::Set('error', '登录失败');
                 redirect("/manage/login/index");
             } else {
                 if (abs(intval($_POST['auto_login']))) {
                     Login::Logon($login_user, true);
                 } else {
                     Login::Logon($login_user);
                 }
                 Session::set("success", "登录成功");
                 redirect("/manage");
             }
         }
     } else {
         $this->display();
     }
 }
开发者ID:Germey,项目名称:yinxingapply,代码行数:28,代码来源:LoginAction.class.php

示例4: GetDefault

 /**
  * Return default skin path from configuration
  */
 private static function GetDefault()
 {
     /**
      *	Multilenguage Support
      */
     $lang = Session::Get('lang');
     if (!$lang) {
         $default = Configuration::Query("/configuration/skins/skin[@default='1']");
         /* We should have one default skin */
         if (!$default) {
             Error::Alert('Default Skin is not defined.');
         }
         /* Default skin should have the language defined */
         $lang = $default->item(0)->getAttribute('lang');
         if (empty($lang)) {
             Error::Alert('Default Skin does not have a language defined.');
         }
         Session::Set('lang', $lang);
     }
     // Util::debug($lang);
     $skin = Configuration::Query("/configuration/skins/skin[@lang='" . $lang . "']/path");
     /* If there is not a skin for the language stored, something is really wrong */
     if (!$skin) {
         Session::Destroy('lang');
         Error::Alert('Could not load the skin for language "' . $lang . '".');
     }
     $default = $skin->item(0)->nodeValue;
     $subdir = Configuration::Query('/configuration/domain/@subdir');
     if ($subdir) {
         $default = '/' . $subdir->item(0)->nodeValue . $default;
     }
     return $default;
 }
开发者ID:floatla,项目名称:ModLayer-Docs,代码行数:36,代码来源:skin.php

示例5: SaveUser

 /**
  * 保存用户
  * @param array $user 用户信息
  */
 public static function SaveUser($user)
 {
     $sessionKey = SESSION_LOGIN_USER;
     $cookieKey = COOKIE_USER_ID;
     $cookieExpireTime = 86400 * Config_User::$loginCookieExpireDay;
     Session::Set($sessionKey, $user);
     Cookie::Set($cookieKey, $user['id'], $cookieExpireTime);
 }
开发者ID:jesse108,项目名称:php_test,代码行数:12,代码来源:User.class.php

示例6: showCode

 /**
  * 获取登录验证码
  */
 public function showCode()
 {
     $ret = $this->get('http://www.douban.com/accounts/login?error=requirecaptcha');
     $captcha = $this->getMatch1('#<img.*? src="(.+?)" alt="captcha"#i', $ret);
     $captcha_id = $this->getMatch1('#name="captcha-id" value="(.*?)"#i', $ret);
     Session::Set('douban_chapcha_id', $captcha_id);
     echo $this->get(urldecode($captcha));
 }
开发者ID:z445056647,项目名称:phx-svns,代码行数:11,代码来源:DoubanSite.class.php

示例7: Set

 public static function Set()
 {
     $ranStr = md5(microtime());
     // Lấy chuỗi rồi mã hóa md5
     $ranStr = substr($ranStr, 0, 6);
     // Cắt chuỗi lấy 6 ký tự
     return Session::Set('captcha', $ranStr);
 }
开发者ID:duonghoaikhanh,项目名称:hondabac,代码行数:8,代码来源:captcha.php

示例8: init

 function init($file)
 {
     $this->excelSheet = $this->_getPhpExcel($file);
     if (!$this->excelSheet) {
         Session::Set("error", "文件损坏或格式错误");
         redirect("/import");
     }
     $this->rowIterator = $this->excelSheet->getRowIterator();
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:9,代码来源:ExcelParserModel.class.php

示例9: action_recover

 public function action_recover($hash = null)
 {
     if (Input::Method() === "POST") {
         if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) {
             // generate a recovery hash
             $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id;
             // and store it in the user profile
             \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username);
             // send an email out with a reset link
             \Package::load('email');
             $email = \Email::forge();
             $html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>';
             // use a view file to generate the email message
             $email->html_body($html);
             // give it a subject
             $email->subject(\Settings::Get('site_name') . ' Password Recovery');
             // GET ADMIN EMAIL FROM SETTINGS?
             $admin_email = Settings::get('admin_email');
             if (empty($admin_email) === false) {
                 $from = $admin_email;
             } else {
                 $from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false)));
             }
             $email->from($from);
             $email->to($user->email, $user->fullname);
             // and off it goes (if all goes well)!
             try {
                 // send the email
                 $email->send();
                 Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!');
             } catch (\Exception $e) {
                 Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email);
                 \Response::redirect_back();
             }
         } else {
             Session::Set('error', 'Sorry there is not a matching email!');
         }
     } elseif (empty($hash) === false) {
         $hash = str_replace(Uri::Create('login/recover/'), '', Uri::current());
         $user = substr($hash, 44);
         if ($user = \Model\Auth_User::find_by_id($user)) {
             // do we have this hash for this user, and hasn't it expired yet , must be within 24 hours
             if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) {
                 // invalidate the hash
                 \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username);
                 // log the user in and go to the profile to change the password
                 if (\Auth::instance()->force_login($user->id)) {
                     Session::Set('current_password', Auth::reset_password($user->username));
                     Response::Redirect(Uri::Create('user/settings'));
                 }
             }
         }
         Session::Set('error', 'Invalid Hash!');
     }
     $this->template->content = View::forge('login/recover');
 }
开发者ID:aircross,项目名称:MeeLa-Premium-URL-Shortener,代码行数:56,代码来源:login.php

示例10: action_profiler

 public function action_profiler()
 {
     $profiler = Session::get('profiler');
     if (empty($profiler) === false) {
         Session::Delete('profiler');
     } else {
         Session::Set('profiler', true);
     }
     Response::Redirect_Back();
 }
开发者ID:aircross,项目名称:MeeLa-Premium-URL-Shortener,代码行数:10,代码来源:admin.php

示例11: before

 public function before()
 {
     parent::before();
     if (\Settings::Get('api') !== true) {
         echo 'API DISABLED';
         Session::Set('error', 'API Disabled');
         Response::redirect(Uri::Base());
         die;
     }
 }
开发者ID:aircross,项目名称:MeeLa-Premium-URL-Shortener,代码行数:10,代码来源:api.php

示例12: Save

 function Save()
 {
     if (isset($this->userData['id'])) {
         $this->db->Update($this->changes)->Where('id', $this->userData['id'])->Limit(1)->Execute(Config::Get('db.table'));
         $result = true;
         if (Session::Get('current_user') && $this->userData['id'] == Session::Get('current_user')->Get('id')) {
             Session::Set('current_user', $this);
         }
     } else {
         $result = $this->db->Insert($this->userData)->Execute(Config::Get('db.table'));
     }
     $this->changes = array();
     return $result;
 }
开发者ID:jobsbe7,项目名称:PokeDev,代码行数:14,代码来源:User.php

示例13: Version

 public static function Version()
 {
     /**
      *	Multi version Support
      */
     $version = Session::Get('version');
     // If version is not set, take the last
     if (!$version) {
         $list = self::Source();
         $version = end($list);
         Session::Set('version', $version);
     }
     return $version;
 }
开发者ID:floatla,项目名称:ModLayer-Docs,代码行数:14,代码来源:application.php

示例14: __construct

 function __construct()
 {
     global $login_user;
     global $partner;
     // login as customer
     if ($this->_get('token')) {
         $cmd_user_id_viapm = intval(Crypt::de($this->_get('token')));
         $login_user = D('CmsUsers')->getById($cmd_user_id_viapm);
         Session::Set("login_user", $login_user);
         Session::Set("via_pm", 1);
     } else {
         $login_user = Session::Get("login_user");
     }
     if (!empty($login_user)) {
         $this->assign("login_user", $login_user);
         $user_info = D(PM_NAME . "://UserInfo")->getUserInfo($login_user['id']);
         if ($user_info && !$user_info['birthday']) {
             $user_info['birthday'] = '1990-01-01';
             // if(!$user_info['submit_time']) {
             //     $user_info['submit_time'] = date('Y-m-d');
             // }
         }
         $this->user_info = $this->userinfo = $user_info;
         define(USER_ID, $login_user['id']);
     } else {
         redirect("/");
     }
     $options = M("Options")->where("autoload = 'Y'")->select();
     $INI = array();
     foreach ($options as $index => $option) {
         $INI[$option['option_name']] = $option['option_value'];
     }
     $this->assign("INI", $INI);
     //  安全过滤
     foreach ($_POST as $k => $v) {
         if (!is_array($v)) {
             $v = preg_replace('/script.*?\\/script/is', '', $v);
             $v = preg_replace('/alert\\(.*?\\)/is', '', $v);
             $v = str_replace(array('eval', 'function', 'onerror', 'alert'), '', $v);
             // $_POST[$k] = htmlspecialchars($v);
         }
     }
     // $this->user_info_items = $this->get_user_info();
 }
开发者ID:Germey,项目名称:yinxingapply,代码行数:44,代码来源:DashboardBaseAction.class.php

示例15: do_main

 function do_main()
 {
     global $ttH;
     $link_action = $ttH->site->get_link($this->modules, $ttH->setting[$this->modules]["change_pass_link"]);
     $err = '';
     if (isset($ttH->post['do_submit'])) {
         /*print_arr($ttH->post);
         		die();*/
         $password_cur = $ttH->func->md25($ttH->post['password_cur']);
         $password = $ttH->func->md25($ttH->post['password']);
         $re_password = $ttH->func->md25($ttH->post['re_password']);
         if (empty($err) && $password_cur != $ttH->data['user_cur']['password']) {
             $err = $ttH->html->html_alert($ttH->lang['global']['err_invalid_password_cur'], "error");
         }
         if (empty($err) && empty($ttH->post['password'])) {
             $err = $ttH->html->html_alert($ttH->lang['global']['err_invalid_password'], "error");
         }
         if (empty($err) && $password != $re_password) {
             $err = $ttH->html->html_alert($ttH->lang['global']['err_invalid_re_password'], "error");
         }
         if (empty($err)) {
             $col = array();
             $col["password"] = $password;
             $col["date_update"] = time();
             $ok = $ttH->db->do_update("user", $col, " user_id='" . $ttH->data['user_cur']['user_id'] . "'");
             if ($ok) {
                 $user_cur = Session::get('user_cur');
                 $user_cur['password'] = $password;
                 $user_cur = Session::Set('user_cur', $user_cur);
                 $err = $ttH->html->html_alert($ttH->lang["user"]["edit_success"], "success");
                 //$ttH->html->redirect_rel($link_action);
             } else {
                 $err = $ttH->html->html_alert($ttH->lang["user"]["edit_false"], "error");
             }
         }
     }
     $data = $ttH->data['user_cur'];
     $data['err'] = $err;
     $data['link_action'] = $link_action;
     $data['content'] = $ttH->site->get_banner('change-pass', 1);
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse("change_pass");
     return $ttH->temp_act->text("change_pass");
 }
开发者ID:duonghoaikhanh,项目名称:shophoa,代码行数:44,代码来源:change_pass.php


注:本文中的Session::Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。