/** * Save a given session to storage. * * @param array $session * @param array $config * @param bool $exists * @return void */ public function save($session, $config, $exists) { extract($config, EXTR_SKIP); $payload = Crypter::encrypt(serialize($session)); $success = \Laravel\Cookie::put(Cookie::payload, $payload, $lifetime, $path, $domain); }
/** * 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']); }
/** * Store a user's token in a long-lived cookie. * * @param string $token * @return void */ protected function remember($token) { $token = Crypter::encrypt($token . '|' . Str::random(40)); $this->cookie($this->recaller(), $token, Cookie::forever); }