Bug #73456 [Opn->Nab]: Problems on unsetting session variable
Edit report at https://bugs.php.net/bug.php?id=73456&edit=1
ID: 73456
Updated by: requinix@php.net
Reported by: sasf54 at gmail dot com
Summary: Problems on unsetting session variable
-Status: Open
+Status: Not a bug
Type: Bug
Package: Session related
Operating System: Linux - Gentoo
PHP Version: 7.0.12
Block user comment: N
Private report: N
New Comment:
session_commit, which is actually just an alias for session_write_close, writes data and ends the
session. If you want to make changes to $_SESSION afterwards then you must call session_start()
again.
Previous Comments:
------------------------------------------------------------------------
[2016-11-03 21:57:31] sasf54 at gmail dot com
Description:
------------
I have a shopping cart.
With unlogged in user, I cannot clean it.
(unset($_SESSION['order']);
session_commit();)
But with a logged in user, it works fine.
(it has some other session variables)
I fixed the bug, with issuing an other session_start() right before the unset block.
Test script:
---------------
// I cannot give you the whole code part :(
// I set the $_SESSION['order'] in an other php file, and it's working fine
session_start();
// some long processing codeing
if (isset($_SESSION['order'])) {
session_start(); // <=== this has to be here to work, without it, does not works
unset($_SESSION['order']);
session_commit();
}
Expected result:
----------------
the $_SESSION['order'] to be unset
(For unlogged in user, it should be an empty session,
for a logged in user, it works fine 'o,O' )
Actual result:
--------------
It should clear the $_SESSION['order'] for unlogged in users too.
(I also tried to add some new values to other session variables to save it, but it was not working
:( )
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73456&edit=1
Thread (5 messages)