I like to have my sites keep you logged in if you're active, but log you out if you've been inactive for a certain amount of time (usually a day, but it depends on the exact project).
To this end, I've been doing this:
setcookie(session_name(),session_id(),...);
I just discovered this function: session_regenerate_id()
With this, it seems like I can just replace my setcookie
code with:
session_regenerate_id(true);
If I understand correctly, this will renew the session with its initial cookie values (path, domain, etc.) and its full expiry time.
Would I be correct in thinking that, in a way, this provides additional security by making it significantly harder to steal a session cookie? (since, after all, the session ID would only be used once before being regenerated).
Essentially, this would end up having the server send a token saying "in your next request, use this ID"...
Is my understanding correct? What would be the downsides (if any) of using such a system?