php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17860 Suggestion: auto detect whether session changed
Submitted: 2002-06-20 00:09 UTC Modified: 2013-08-10 04:57 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: Xuefer at 21cn dot com Assigned: yohgaki (profile)
Status: Closed Package: Session related
PHP Version: 4.2.1 OS: all
Private report: No CVE-ID: None
 [2002-06-20 00:09 UTC] Xuefer at 21cn dot com
session data changed need ===> session update
session active need only  ===> session "mtime" update, and don't need to update frequently

sometime, it's hard for ourself do judge whether to open a session in readonly mode.

it is possible to detect whether $_SESSION is changed ?
i just do it using md5 now, but if there's and capability to do internally, e.g.: a flag set when session changed, should be faster than md5.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-20 00:15 UTC] Xuefer at 21cn dot com
yes, i know, a file handler don't need to update mtime, they have "atime", but for a drive which not local, or sql_session_handler, a remote sql server, it's nightmare to send session data every page load

we need to detect whether "it's REALLY need to update session data"
 [2011-01-01 00:43 UTC] jani@php.net
-Package: Feature/Change Request +Package: Session related
 [2012-03-30 10:01 UTC] yohgaki@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: yohgaki
 [2012-03-30 10:01 UTC] yohgaki@php.net
I'll implement by checking hash of serialized session data.
Saving unneeded session writes is good for many apps.
 [2013-08-10 04:57 UTC] yohgaki@php.net
-Status: Assigned +Status: Closed
 [2013-08-10 04:57 UTC] yohgaki@php.net
Will be available 5.6 or later.
 [2014-11-23 21:09 UTC] bouvrette dot nicolas at gmail dot com
Is there any configuration so avoid this new behavior? I myself manage the session expiration in the DB and need that every page load force a write even if nothing has changed.

I checked here and couldn't find anything about this new feature:

http://php.net/manual/en/session.configuration.php

This is breaking my code right now... could we implement a way to configure this?
 [2014-11-23 21:35 UTC] bouvrette dot nicolas at gmail dot com
Actually I found a work around adding this in my session close method :

    public function close() {
        $this->write($this->id, serialize($_SESSION));
        return true;
    }

It's fine but if you please let me know if you are planning to have a way to configure this so I will remove my code.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC