I’m using php Sessions on my website and it seems like they are “disappearing” at random intervals. I don’t know if they are timing out due to inactivity or if something is wrong with my code, but is there some way to control the sessions of when they expire?
Like can I put something in my code or change something in the php.ini file?
Update- So just and update here, I switched hosts and magically the sessions started working. I have no clue what was wrong but apparently they did not want to work correctly.
Random expiration is a classical symptom of session data directory shared by several applications: the one with the shortest
session.gc_maxlifetimetime is likely to remove data from other applications. The reason:The builtin file handler doesn’t track who owns what session file (it just matches file name with session ID):
My advice is that you configure a private custom session directory for your application. That can be done with the
session_save_path()function or setting thesession.save_pathconfiguration directive. Please check your framework’s documentation for the precise details on how to do it in your own codebase.