Example #1
0
 /**
  * Test the Cookie::get method.
  *
  * @group laravel
  */
 public function testGetMethodCanReturnValueOfCookies()
 {
     Cookie::$jar['foo'] = array('value' => Cookie::hash('bar') . '+bar');
     $this->assertEquals('bar', Cookie::get('foo'));
     Cookie::put('bar', 'baz');
     $this->assertEquals('baz', Cookie::get('bar'));
 }
Example #2
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 (\Laravel\Cookie::has(Cookie::payload)) {
         $cookie = Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload));
         return unserialize($cookie);
     }
 }
Example #3
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');
 }
Example #4
0
 /**
  * Create the session payload and load the session.
  *
  * @return void
  */
 public static function load()
 {
     static::start(Config::get('session.driver'));
     static::$instance->load(Cookie::get(Config::get('session.cookie')));
 }
Example #5
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)));
     }
 }
Example #6
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)));
     }
 }
Example #7
0
 protected function recall()
 {
     $cookie = Cookie::get($this->recaller());
     if (!is_null($cookie)) {
         return head(explode('|', Crypter::decrypt($cookie)));
     }
 }