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


PHP Session::save方法代码示例

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


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

示例1: unsetUser

 public function unsetUser()
 {
     if (\Session::has("User")) {
         \Session::forget("User");
         \Session::save();
     }
 }
开发者ID:hanhan1978,项目名称:owl,代码行数:7,代码来源:AuthService.php

示例2: doLogin

	function doLogin() {
		$this->save("login");
		if (empty($this->messages)) {
			$select = new Select("users");
			$select->add(Exp::eq("username", $this->login["username"]));
			$user = DB::unique($select);
			if (empty($user)) {
				$this->addMsgMessage("error.fieldNotFound", "login.username");
				Msg::save($this->messages);
				Apu::redirect("login");
			}
			if ($user["password"] != $this->login["password"]) {
				$this->addMsgMessage("error.fieldNotFound", "login.password");
				Msg::save($this->messages);
				Apu::redirect("login");
			}	
			$date = new Date();
			Session::save(LOGIN_SCOPE, $user, "user");
			Session::save(LOGIN_SCOPE, $date, "last_access");
			$this->remove();
			Apu::redirect("frame");
		} else {
			Msg::save($this->messages);
			Apu::redirect("login");
		}
	}
开发者ID:reekoheek,项目名称:php-fw,代码行数:26,代码来源:LoginAction.php

示例3: sign_up

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function sign_up()
 {
     //
     $user = Input::get('username');
     $realname = Input::get('realname');
     $pass = Input::get('password');
     $response = DB::table('users')->select('iduser', 'realname', 'username')->where('password', $pass)->where(function ($query) use($user) {
         $query->orWhere('username', $user);
     })->get();
     if (!$response) {
         $response = DB::table('users')->select('iduser', 'realname', 'username')->where(function ($query) use($user) {
             $query->orWhere('username', $user);
         })->get();
         if ($response) {
             return Response::json(array('user' => false));
         }
         DB::table('users')->insert(array('username' => $user, 'realname' => $realname, 'password' => $pass));
         $response = DB::table('users')->select('iduser', 'realname', 'username')->where('password', $pass)->where(function ($query) use($user) {
             $query->orWhere('username', $user);
         })->get();
         if (!$response) {
             return Response::json(array('user' => false));
         } else {
             Session::put('user', $response[0]);
             Session::save();
             return Response::json(array('user' => Session::get('user')));
         }
     } else {
         Session::put('user', $response[0]);
         Session::save();
         return Response::json(array('user' => Session::get('user')));
     }
 }
开发者ID:lhkingkong,项目名称:kill-them-all-back,代码行数:38,代码来源:UserController.php

示例4: sign_up

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function sign_up()
 {
     //
     $admin = Input::get('username');
     $pass = Input::get('password');
     $response = DB::table('admin')->select('idadmin', 'username')->where('password', $pass)->where(function ($query) use($admin) {
         $query->orWhere('username', $admin);
     })->get();
     if (!$response) {
         DB::table('admin')->insert(array('username' => $admin, 'password' => $pass));
         $response = DB::table('admin')->select('idadmin', 'username')->where('password', $pass)->where(function ($query) use($admin) {
             $query->orWhere('username', $admin);
         })->get();
         if (!$response) {
             return Response::json(array('admin' => false));
         } else {
             Session::put('admin', $response[0]);
             Session::save();
             return Response::json(array('admin' => Session::get('admin')));
         }
     } else {
         Session::put('admin', $response[0]);
         Session::save();
         return Response::json(array('admin' => Session::get('admin')));
     }
 }
开发者ID:lhkingkong,项目名称:kill-them-all-back,代码行数:31,代码来源:AdminController.php

示例5: sendFile

 /**
  * Start a big file download on Laravel Framework 4.0 / 4.1
  * Source (originally for Laravel 3.*) : http://stackoverflow.com/questions/15942497/why-dont-large-files-download-easily-in-laravel
  * @param  string $path    Path to the big file
  * @param  string $name    Name of the file (used in Content-disposition header)
  * @param  array  $headers Some extra headers
  */
 public function sendFile($path, $name = null, array $headers = array())
 {
     if (is_null($name)) {
         $name = basename($path);
     }
     $file = new \Symfony\Component\HttpFoundation\File\File($path);
     $mime = $file->getMimeType();
     // Prepare the headers
     $headers = array_merge(array('Content-Description' => 'File Transfer', 'Content-Type' => $mime, 'Content-Transfer-Encoding' => 'binary', 'Expires' => 0, 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'public', 'Content-Length' => \File::size($path), 'Content-Disposition' => 'attachment; filename=' . $name), $headers);
     $response = new \Symfony\Component\HttpFoundation\Response('', 200, $headers);
     // If there's a session we should save it now
     if (\Config::get('session.driver') !== '') {
         \Session::save();
     }
     session_write_close();
     if (ob_get_length()) {
         ob_end_clean();
     }
     $response->sendHeaders();
     // Read the file
     if ($file = fopen($path, 'rb')) {
         while (!feof($file) and connection_status() == 0) {
             print fread($file, 1024 * 8);
             flush();
         }
         fclose($file);
     }
     // Finish off, like Laravel would
     \Event::fire('laravel.done', array($response));
     $response->send();
 }
开发者ID:teewebapp,项目名称:backup,代码行数:38,代码来源:AdminController.php

示例6: theme

	function theme() {
		$theme = Session::load(APU_SCOPE, "theme");
		if (empty($theme)) {
			$theme = $GLOBALS["CFG_APU"]->THEME;
			Session::save(APU_SCOPE, $theme, "theme");
		}
		return Apu::base().'/themes/'.$theme;
	}
开发者ID:reekoheek,项目名称:php-fw,代码行数:8,代码来源:apu.php

示例7: loginComplete

 /**
  * When login is complete, save the SSPAuthentication object to the session
  */
 public final function loginComplete()
 {
     //Use the same session as SimpleSAMLphp to avoid session state loss
     Session::start(SimpleSAML_Session::getInstance()->getSessionId());
     Session::set('ssp_current_auth_source', $this->getAuthSource()->getAuthId());
     Session::set('ssp_current_auth_class', get_class($this));
     Session::save();
 }
开发者ID:helpfulrobot,项目名称:antons-silverstripe-ssp,代码行数:11,代码来源:SSPAuthenticator.php

示例8: authenticate

 /**
  * Sends the authentication process down the SAML rabbit hole. It will trigger
  * the IdP redirection via the 3rd party implementation, and if successful, the user
  * will be delivered to the SAMLController::acs.
  *
  * @param array $data
  * @param Form $form
  * @return bool|Member|void
  * @throws SS_HTTPResponse_Exception
  */
 public static function authenticate($data, Form $form = null)
 {
     // $data is not used - the form is just one button, with no fields.
     $auth = Injector::inst()->get('SAMLHelper')->getSAMLAuth();
     Session::set('BackURL', isset($data['BackURL']) ? $data['BackURL'] : null);
     Session::save();
     $auth->login(Director::absoluteBaseURL() . 'saml/');
 }
开发者ID:eLBirador,项目名称:silverstripe-activedirectory,代码行数:18,代码来源:SAMLAuthenticator.php

示例9: acs

 /**
  * Assertion Consumer Service
  *
  * The user gets sent back here after authenticating with the IdP, off-site.
  * The earlier redirection to the IdP can be found in the SAMLAuthenticator::authenticate.
  *
  * After this handler completes, we end up with a rudimentary Member record (which will be created on-the-fly
  * if not existent), with the user already logged in. Login triggers memberLoggedIn hooks, which allows
  * LDAP side of this module to finish off loading Member data.
  *
  * @throws OneLogin_Saml2_Error
  */
 public function acs()
 {
     $auth = Injector::inst()->get('SAMLHelper')->getSAMLAuth();
     $auth->processResponse();
     $error = $auth->getLastErrorReason();
     if (!empty($error)) {
         SS_Log::log($error, SS_Log::ERR);
         Form::messageForForm("SAMLLoginForm_LoginForm", "Authentication error: '{$error}'", 'bad');
         Session::save();
         return $this->getRedirect();
     }
     if (!$auth->isAuthenticated()) {
         Form::messageForForm("SAMLLoginForm_LoginForm", _t('Member.ERRORWRONGCRED'), 'bad');
         Session::save();
         return $this->getRedirect();
     }
     $decodedNameId = base64_decode($auth->getNameId());
     // check that the NameID is a binary string (which signals that it is a guid
     if (ctype_print($decodedNameId)) {
         Form::messageForForm("SAMLLoginForm_LoginForm", "Name ID provided by IdP is not a binary GUID.", 'bad');
         Session::save();
         return $this->getRedirect();
     }
     // transform the NameId to guid
     $guid = LDAPUtil::bin_to_str_guid($decodedNameId);
     if (!LDAPUtil::validGuid($guid)) {
         $errorMessage = "Not a valid GUID '{$guid}' recieved from server.";
         SS_Log::log($errorMessage, SS_Log::ERR);
         Form::messageForForm("SAMLLoginForm_LoginForm", $errorMessage, 'bad');
         Session::save();
         return $this->getRedirect();
     }
     // Write a rudimentary member with basic fields on every login, so that we at least have something
     // if LDAP synchronisation fails.
     $member = Member::get()->filter('GUID', $guid)->limit(1)->first();
     if (!($member && $member->exists())) {
         $member = new Member();
         $member->GUID = $guid;
     }
     $attributes = $auth->getAttributes();
     foreach ($member->config()->claims_field_mappings as $claim => $field) {
         if (!isset($attributes[$claim][0])) {
             SS_Log::log(sprintf('Claim rule \'%s\' configured in LDAPMember.claims_field_mappings, but wasn\'t passed through. Please check IdP claim rules.', $claim), SS_Log::WARN);
             continue;
         }
         $member->{$field} = $attributes[$claim][0];
     }
     $member->SAMLSessionIndex = $auth->getSessionIndex();
     // This will throw an exception if there are two distinct GUIDs with the same email address.
     // We are happy with a raw 500 here at this stage.
     $member->write();
     // This will trigger LDAP update through LDAPMemberExtension::memberLoggedIn.
     // Both SAML and LDAP identify Members by the GUID field.
     $member->logIn();
     return $this->getRedirect();
 }
开发者ID:eLBirador,项目名称:silverstripe-activedirectory,代码行数:68,代码来源:SAMLController.php

示例10: memberLoggedOut

 function memberLoggedOut()
 {
     if ($this->_cache_session) {
         $restoreStates = array_diff_key($this->_cache_session, array('loggedInAs' => true));
         foreach ($restoreStates as $k => $v) {
             Session::set($k, $v);
         }
         Session::save();
     }
 }
开发者ID:jeffreyguo,项目名称:SilverStripe-Behat-Test-Demo,代码行数:10,代码来源:DemoTestSessionMemberExtension.php

示例11: executeRequest

 public function executeRequest()
 {
     $this->initializeDatabase();
     Session::init();
     Flash::__load_from_session();
     RouteMap::init();
     RouteMap::dispatch();
     Flash::__save_to_session();
     Session::save();
     $this->disposeDatabase();
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:11,代码来源:ActionEngine.class.php

示例12: onBeforeInit

 function onBeforeInit()
 {
     if (isset($_REQUEST['FAKE_IP'])) {
         Session::set('FAKE_IP', $_REQUEST['FAKE_IP']);
         Session::save();
     }
     if (isset($_REQUEST['CLEAR_FAKE_IP'])) {
         Session::clear('FAKE_IP');
         Session::save();
     }
 }
开发者ID:silverstripers,项目名称:continental-content,代码行数:11,代码来源:ContinentalControllerExtension.php

示例13: lang

	function lang($lang = null) {
		if ($lang == null) {
			$sessionLang = Session::load(MSG_SCOPE, "lang");
			if (empty($sessionLang)) {
				Session::save(MSG_SCOPE, Locale::_defaultBrowserLang(), "lang");
			}
			return Session::load(MSG_SCOPE, "lang");
		} else {
			Session::save(MSG_SCOPE, $lang, "lang");
		}
	}
开发者ID:reekoheek,项目名称:php-fw,代码行数:11,代码来源:Locale.php

示例14: createFolder

 /**
  * Create a child folder given a parent node
  *
  * @param Node $parent
  * @param string $name
  */
 private function createFolder($parent, $name)
 {
     if (!$this->getConnection()) {
         return null;
     }
     $childassoc = preg_replace('/[^a-z0-9:.-]/', '', $name);
     $node = $parent->createChild('cm_folder', 'cm_contains', 'cm_' . $childassoc);
     $node->cm_name = $name;
     $this->alfresco->save();
     return $node;
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:17,代码来源:AlfrescoFileService.php

示例15: createToken

 /** Сохранение токена в БД */
 public function createToken($expire = null)
 {
     $u = $this->getUser();
     $t = sha1(uniqid());
     $s = new \Session($this->getManager());
     $s->setToken($t);
     $s->setUserId($u->getId());
     $s->setIp($this->getRequest()->getClientIp());
     $s->setExpiresAt(is_numeric($expire) ? date('d.m.Y', $expire) : $expire);
     $s->save();
     return $t;
 }
开发者ID:sqrt-pro,项目名称:framework,代码行数:13,代码来源:Auth.php


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