php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #11982 session_expires()
Submitted: 2001-07-09 11:47 UTC Modified: 2013-08-07 08:52 UTC
Votes:11
Avg. Score:4.2 ± 0.9
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: arni at linux dot is Assigned: yohgaki (profile)
Status: Wont fix Package: Session related
PHP Version: 4.0.6 OS: Windows2000
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2001-07-09 11:47 UTC] arni at linux dot is
I have a feature request for the session module in php. This request should be self-explaining. I would appreciate if a session_expires(int seconds) function would be implemented. Defining when a session will expire in seconds.

This function should destroy the session if the session is expired. Also, let the function return 1 if the session is expired, and 0 if it's not expired. Then it could be used in cases like:

if(session_is_expired()) {
  ...expired...die
}
else {
  ...not expired, continue...
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-01 16:05 UTC] jani@php.net
-Package: Feature/Change Request +Package: Session related
 [2011-11-08 03:20 UTC] yohgaki at ohgaki dot net
Basically, session expiration is depend on browser's cookie expiration. 
Therefore, when session is expired, session cookie is gone.

We can implement this feature in session module via new session data structure. 
If we do, there will be compatibility issues. For instance, PERL or other 
languages have PHP session data parser to share session data with PHP. New data 
structure will break them.

I usually do this in my PHP script. e.g. 

$_SESSION['expire'] = time() + 7200; // somewhere

then 

if ($_SESSION['expire'] < time()) ..do something.. // elsewhere

I'm not sure if we should do this in session module.
 [2011-11-08 03:25 UTC] yohgaki at ohgaki dot net
BTW, current session data structure has rather strange data structure to support 
register globals.

We can introduce new and cleaner data structure that can easily fetch session 
data directly from session data. i.e. use plain serialize() for session data 
serialization.
 [2013-08-07 08:52 UTC] yohgaki@php.net
-Status: Analyzed +Status: Wont fix
 [2013-08-07 08:52 UTC] yohgaki@php.net
Since how expire session is application dependent, make this request as won't 
fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC