예제 #1
0
파일: cookie.php 프로젝트: jknox12/mirror
 /**
  * Load a session from storage by a given ID.
  *
  * If no session is found for the ID, null will be returned.
  *
  * @param  string  $id
  * @return array
  */
 public function load($id)
 {
     if (\Laravel\Cookie::has(Cookie::payload)) {
         $cookie = Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload));
         return unserialize($cookie);
     }
 }
예제 #2
0
 /**
  * Test the Auth::login method.
  *
  * @group laravel
  */
 public function testLoginStoresRememberCookieWhenNeeded()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     $this->setServerVar('HTTPS', 'on');
     // Set the session vars to make sure remember cookie uses them
     Config::set('session.path', 'foo');
     Config::set('session.domain', 'bar');
     Config::set('session.secure', true);
     Auth::login(1, true);
     $this->assertTrue(isset(Cookie::$jar['laravel_auth_drivers_fluent_remember']));
     $cookie = Cookie::get('laravel_auth_drivers_fluent_remember');
     $cookie = explode('|', Crypter::decrypt($cookie));
     $this->assertEquals(1, $cookie[0]);
     $this->assertEquals('foo', Cookie::$jar['laravel_auth_drivers_fluent_remember']['path']);
     $this->assertEquals('bar', Cookie::$jar['laravel_auth_drivers_fluent_remember']['domain']);
     $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['secure']);
     Auth::logout();
     $this->setServerVar('HTTPS', 'off');
 }
예제 #3
0
 /**
  * Load a session from storage by a given ID.
  *
  * If no session is found for the ID, null will be returned.
  *
  * @param  string  $id
  * @return array
  */
 public function load($id)
 {
     if (C::has(Cookie::payload)) {
         return unserialize(Crypter::decrypt(C::get(Cookie::payload)));
     }
 }
예제 #4
0
 /**
  * Attempt to find a "remember me" cookie for the user.
  *
  * @return string|null
  */
 protected function recall()
 {
     $cookie = Cookie::get($this->recaller());
     // By default, "remember me" cookies are encrypted and contain the user
     // token as well as a random string. If it exists, we'll decrypt it
     // and return the first segment, which is the user's ID token.
     if (!is_null($cookie)) {
         return head(explode('|', Crypter::decrypt($cookie)));
     }
 }
예제 #5
0
 protected function recall()
 {
     $cookie = Cookie::get($this->recaller());
     if (!is_null($cookie)) {
         return head(explode('|', Crypter::decrypt($cookie)));
     }
 }