/** * Send the session ID cookie to the browser. * * @param array $config * @return void */ protected function cookie($config) { extract($config, EXTR_SKIP); $minutes = !$expire_on_close ? $lifetime : 0; Cookie::put($cookie, $this->session['id'], $minutes, $path, $domain, $secure); }
/** * 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'); }
/** * Test the Cookie::forget method. * * @group laravel */ public function testForgetSetsCookieWithExpiration() { Cookie::forget('bar', 'path', 'domain'); // Shouldn't be able to test this cause while we indicate -2000 seconds // cookie expiration store timestamp. //$this->assertEquals(-2000, Cookie::$jar['bar']['expiration']); $this->assertEquals('path', Cookie::$jar['bar']['path']); $this->assertEquals('domain', Cookie::$jar['bar']['domain']); $this->assertFalse(Cookie::$jar['bar']['secure']); }
/** * 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'))); }
/** * Delete a session from storage by a given ID. * * @param string $id * @return void */ public function delete($id) { \Laravel\Cookie::forget(Cookie::payload); }
/** * Store an authentication cookie. * * @param string $name * @param string $value * @param int $minutes * @return void */ protected function cookie($name, $value, $minutes) { // When setting the default implementation of an authentication // cookie we'll use the same settings as the session cookie. // This typically makes sense as they both are sensitive. $config = Config::get('session'); extract($config); Cookie::put($name, $value, $minutes, $path, $domain, $secure); }
/** * Delete a session from storage by a given ID. * * @param string $id * @return void */ public function delete($id) { C::forget(Cookie::payload); }
/** * Test the Auth::recall method. * * @group laravel */ public function testUserCanBeRecalledViaCookie() { Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); $cookie = Crypter::encrypt('1|' . Str::random(40)); Cookie::forever('authloginstub_remember', $cookie); $auth = new AuthLoginStub(); $this->assertEquals('Taylor Otwell', $auth->user()->name); $this->assertTrue($auth->user()->id === $_SERVER['auth.login.stub']['user']); }
protected function cookie($name, $value, $minutes) { $config = Config::get('session'); extract($config); Cookie::put($name, $value, $minutes, $path, $domain, $secure); }