Edit report at https://bugs.php.net/bug.php?id=52982&edit=1

 ID:                 52982
 Updated by:         ar...@php.net
 Reported by:        php dot net at kenman dot net
 Summary:            Expose php_session_active to userland via new
                     function (patch included)
-Status:             Assigned
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Session related
 PHP Version:        5.3.3
 Assigned To:        arpad
 Block user comment: N
 Private report:     N

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2011-08-29 21:29:15] ar...@php.net

Automatic comment from SVN on behalf of arpad
Revision: http://svn.php.net/viewvc/?view=revision&revision=315745
Log: Expose session status via new function, session_status (Req #52982)

------------------------------------------------------------------------
[2011-07-26 18:53:23] ar...@php.net

The following patch has been added/updated:

Patch Name: php-trunk-session-status-bools
Revision:   1311706403
URL:        
https://bugs.php.net/patch-display.php?bug=52982&patch=php-trunk-session-status-bools&revision=1311706403

------------------------------------------------------------------------
[2011-07-26 18:52:27] ar...@php.net

The following patch has been added/updated:

Patch Name: php-trunk-session-status
Revision:   1311706347
URL:        
https://bugs.php.net/patch-display.php?bug=52982&patch=php-trunk-session-status&revision=1311706347

------------------------------------------------------------------------
[2011-07-26 14:31:21] php dot net at kenman dot net

Thank you very much, Arpad; my rudimentary C skills were barely enough for me 
to 
craft the patch (which I somehow managed to compile and use), and so I 
appreciate 
the background info. I would be happy with any solution that helps me to solve 
the 
problem!

------------------------------------------------------------------------
[2011-07-25 22:37:37] ar...@php.net

If you're trying to establish whether it's safe to start your own session, this 
patch is deficient because PS(session_status) is not a boolean - it could also 
be php_session_disabled.

I'd imagine robust code to handle this (rather unusual) case where you require 
a session but don't know if it's present, would be something like:

if (session_is_available()) {
    if (!session_is_active()) {
        if (headers_sent()) {
            // bail out
        } else {
            session_start();
        }
    }
} else {
    // bail out
}

We could instead provide a session_status() function which corresponds to the 
internal enum (returning SESSION_DISABLED, SESSION_NONE or SESSION_ACTIVE.)

I assume this is what Kalle was talking about WRT exposing the other values.

Both options are trivial patches. The former seems friendlier but more prone to 
error.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=52982


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=52982&edit=1

Reply via email to