Req #40275 [Opn->Csd]: FREQ: Ability to access sessions without increasing their lifetime

From: Date: Wed, 07 Jul 2021 11:34:07 +0000
Subject: Req #40275 [Opn->Csd]: FREQ: Ability to access sessions without increasing their lifetime
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234861@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=40275&edit=1 ID: 40275 Updated by: cmb@php.net Reported by: graced at monroe dot wednet dot edu Summary: FREQ: Ability to access sessions without increasing their lifetime -Status: Open +Status: Closed Type: Feature/Change Request Package: Session related Operating System: Irrelevant PHP Version: 5.2.0 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: The session timestamp is supposed to be updated on write, not on read. So calling session_start() doesn't extend the lifespan of the session, but rather the implicit session_write_close() at the end of the script. You can avoid that by calling session_abort(). > Additionally, with this feature an additional function > (session_lifetime_remaining?) which returns the number of seconds > until a session expires would be ideal It wouldn't be possible to give the exact value, since that depends on when the GC will actually be triggered. But anyhow, you could use a custom session handler to implement this. Previous Comments: ------------------------------------------------------------------------ [2007-01-29 17:49:23] graced at monroe dot wednet dot edu Description: ------------ It's not readily apparent whether there is any way to do this with PHP's built-in session handler, so I figured I would write a request: It would be nice to have a way to access a session (ala session_start()) in such a way where the lifetime of that session is not extended. The intended application is for a PHP script that responds to polling (through Javascript) every ~5 minutes to report any new events. For example, Javascript code might poll the server periodically to see if the user has any new messages on a forum. Using session_start() in this situation is not neccessarily ideal as it would keep the user perpetually logged in until their webbrowser was closed. The idea is that interactive actions (a user clicking on a link to another page on the site or submitting a form) should continue to increase the lifetime of a session, but noninteractive ones should not. However, they should still be able to access (and potentially modify) session variables. Additionally, with this feature an additional function (session_lifetime_remaining?) which returns the number of seconds until a session expires would be ideal -- allowing a user to be warned of impending logout due to inactivity. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=40275&edit=1

« previous php.bugs (#234861) next »