note 88731 deleted from function.session-start by peehaa
| From: | peehaa@php.net | Date: | Fri, 09 Dec 2016 22:14:30 +0000 |
| Subject: | note 88731 deleted from function.session-start by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208340@lists.php.net to get a copy of this message | ||
Note Submitter: yesmarklapointe at hotmail dot com
----
Here is some info about how to use SID with session_start().
Experiment run on WAMPserver, PHP version 5.2.6.
Using FireFox 3.0.
The definition found at http://www.php.net/manual/en/session.constants.php
describes SID is a âpre-defined constantâ containing either:
1). the session name and session ID in the form of "name=ID" .
This is the same name as would be returned by session_name(), and the same id as would be returned
by session_id().
2). Or an empty string, if the session ID was set in an appropriate session cookie.
Example code:
<?php
session_start();
echo '<a href="page2.php?' . SID . '">page2</a>';
?>
This code will yield in the browser one of the following:
a). âpage 2â (as a hyperlink, but mouseover shows the link is to something in the
form of
http://www.example.com/page2.php?PHPSESSID=e2bd7072....
)
b). âpage 2â (as a hyperlink, but mouseover shows http://www.example.com/page2.php? )
Which result is determined by whether or not the browser is sending a matching session cookie back
to the script. Result âaâ above always appears at least initially since the script
hasnât yet set a cookie and neither has it been done automatically yet by the php.ini setting
session.use_cookies. However, after refreshing or using the back button, the form in "b"
will appear because then the cookie exists (either you set it or session.use_cookies did it
automatically).