note 42594 rejected from ref.session by betz
| From: | betz@php.net | Date: | Thu, 12 Aug 2004 03:42:42 +0000 |
| Subject: | note 42594 rejected from ref.session by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74513@lists.php.net to get a copy of this message | ||
Note Submitter: proteus@proteusworld.com
----
I found a strange (to me at least) behaviour with sessions when using HTTPS and thought to share it,
might save others some headaches.
Let's say that $_SESSION["message"] contains "old_message". Take the
following code:
$old_message = $_SESSION["message"];
$_SESSION["message"] = "new message";
echo "The message was: ".$old_message;
Now, over HTTP you would get the expected output ("old_message"). But over HTTPS the
output will contain "new_message".
I don't know why this happends, nor do I know a proper workaround. You can use
session_unregister("message") if you want $old_message to preserve its value, but this
means you can't set anymore a new value for $_SESSION["message"].