Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 'JAR.lifetime' param to set expiration in seconds #178

Closed
sam2kb opened this issue Dec 13, 2016 · 3 comments
Closed

Add a 'JAR.lifetime' param to set expiration in seconds #178

sam2kb opened this issue Dec 13, 2016 · 3 comments

Comments

@sam2kb
Copy link

sam2kb commented Dec 13, 2016

This code is from Base::set()

$jar=$this->unserialize($this->serialize($this->hive['JAR']));
$jar['expire']-=$time;
call_user_func_array('session_set_cookie_params',$jar);

Why would you subtract time, this makes JAR.expire value negative. Unless you add time() first, but why on Earth would one add time and then subtract it later.

@ikkez
Copy link
Member

ikkez commented Dec 13, 2016

From the quick reference JAR

expire Unix timestamp, when the cookie should expire. Default: 0

So you had to set a unix timestamp to JAR.expire, which is usually greater than time(). In case of the session cookie parameter, this piece of code you've picked just converts the unix timestamp to a simple seconds-based lifetime value by substracting $time, which is necessary because the expire parameter in setcookie and session_set_cookie_params are different.

@sam2kb
Copy link
Author

sam2kb commented Dec 13, 2016

That's right, one can't just set expiration time in seconds in the config file

[JAR]
expire = 604800
domain = whatever.tld

Instead, this is why I have to to
$f3->set('JAR.expire', time()+604800);

So my question is why do we require Unix timestamp instead of time in seconds like in session_set_cookie_params

@sam2kb
Copy link
Author

sam2kb commented Dec 13, 2016

Ok I see now that JAR.expire is used elsewhere in the code as timestamp and we are not supposed to define this in text config.
Should we then have another lifetime param in seconds for use in config files?

@sam2kb sam2kb changed the title Weird logic in 'JAR.expire' Add a 'JAR.lifetime' param to set session expiration in seconds Dec 13, 2016
@sam2kb sam2kb changed the title Add a 'JAR.lifetime' param to set session expiration in seconds Add a 'JAR.lifetime' param to set expiration in seconds Dec 13, 2016
ikkez added a commit to ikkez/fatfree-core that referenced this issue Jan 2, 2018
ikkez added a commit that referenced this issue Jan 12, 2018
@ikkez ikkez closed this as completed Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants