Monday, 15 April 2013

Laravel cookie session lifetime -



Laravel cookie session lifetime -

i used laravel oauth2 client, , need maintain token cookies. so, set driver cookie , maintain default value lifetime 120

when user check remember me on login, tried alter lifetime code:

$lifetime = time() + 60 * 60 * 24 * 365;// 1 year config::set('session.lifetime', $lifetime);

but without success. in controller checked value of lifetime , every time default value.

\log::info(\config::get('session.lifetime'));

edit #1:

it enough?

if(input::has('rememberme')) { $lifetime = time() + 60 * 60 * 24 * 365; // 1 year session::put('expires', $lifetime); }

edit #2:

i set acess_token key on same way expires in illustration above, like:

public function signin() { /** * code getting *client_code* , *client_state* api server */ $access_token = $this->provider->getaccesstoken('authorization_code', $form_data); // $access_token object , contain info (access_token, refresh_token, expires) session::put('access_token', $access_token); session::put('refresh_token', $access_token->refreshtoken); session::put('token_expires', $access_token->expires); if(input::has('rememberme')) { $lifetime = time() + 60 * 60 * 24 * 365; // 1 year session::put('expires', $lifetime); } homecoming response.... }

this 'default' laravel session (i changed driver file cookie in /app/config/session.php). know life time should set in /app/config/session.php file, can see need longer life time remember me option

actually when setting value in controller:

$lifetime = time() + 60 * 60 * 24 * 365;// 1 year config::set('session.lifetime', $lifetime);

it's not updating value in file, instead sets current request (in memory) , when check value using controller/request this:

config::get('session.lifetime');

you getting value original value file system. it's mentioned in documentation given below:

configuration values set @ run-time set current request, , not carried on subsequent requests.

session cookies laravel lifetime

No comments:

Post a Comment