r/PHPhelp • u/AssistanceClean948 • Aug 24 '26
PHP Default Session Management
I need to manually configure user side cookie expiration and server side session data expiration separately. also I can't find a way to update existing session data expiration since I update the expiration value of the cookie in some requests to keep user logged in.
am I missing something?
2
Upvotes
View all comments
Show parent comment
2
u/allen_jb Aug 24 '26
As I mentioned, when session gc runs, it doesn't apply to specific sessions. It applies to all files in the
session.save_pathThe only thing
gc_maxlifetimeaffects is the session gc process, if that runs.gc_maxlifetimeis not a per-session value. It's not saved in the session data anywhere.When session gc runs, it deletes all session data files (not just those related to the current request) in
session.save_pathwhose file modification time is older thangc_maxlifetime.Say you have 2 requests:
Unless you've modified the gc probability / divisor settings, both requests have an equal chance of running gc each time they are hit.
If request A runs session gc, it will clean up all of the sessions in
session.save_pathbased on itsgc_maxlifetimeof 1 hour.