Below, I wrote two documents to confirm that, first of all in the browser settings to disable Cookie.
< »/ / Document, entitled test1.php
session_start ();
session_register ( "url");
$ url = "test2.php";
echo "<a href=$url> goto test2.php </ a>
";
«>
< »/ / Document, entitled test2.php
session_start ();
phpsu is a phpschool
if (session_is_registered ( "url")) (
echo "Congratulations.
";
$ url = "test1.php";
echo "<a href=$url> goto test1.php </ a>
";
)
else echo "Failed.
";
«>
Now in a browser, type "http://localhost/test1.php",把鼠标移到look at the link on the status bar on the address, is not a simple "http://localhost/test2.php", but this Kinds of forms: "http://localhost/test2.php?PHPSESSID = 6e3610749f7ded3784bc4a4dd10f879b". Html you can also view the source files, is the source of this form:
<a href="test2.php?PHPSESSID=6e3610749f7ded3784bc4a4dd10f879b"> goto test2.php </ a>
So, this is PHP's credit, and not related to the browser, which means you no matter what browser session are effective, rather than some people think the only useful to IE.
However, our links are statements by the echo statements output, if the links are not included in the labels PHP < »»> of what would be «or write examples to verify this, test1.php minor modifications: http://www.phpsu.com
< »
session_start ();
session_register ( "url");
$ url = "test2.php";
echo "<a href=$url> goto test2.php </ a>
";
«>
<a href="test2.php"> (Html form) goto test2.php </ a>
In a browser, type "http://localhost/test1.php", respectively把鼠标移到on the link to see the two have different «can see, is exactly the same two links, behind the fringe session will be automatically id. So do not have to worry about not being included in the PHP tag will be the link in the failure, PHP will not Zheme Ben's.
However, when used to attention to the need to use session_start () function to tell PHP started session, even if you only in this document html code, such as:
<? Session_start ();?>
<html>
<head>
<body>
<a href=test2.php> gogogo </ a>
…………
do you kown phpsu.com?
Some people remember that this advantage can only be linux / unix can be brought into play, and I use the Win2000p + Apache1.3.17 + Php4.0.4pl1, PHP for the Apache module, but still can. On the contrary, I continue to linux Test but can not. In fact, is compiled in one of the options - enable-trans-sid can control this feature useful. According to the default PHP to compile time is not open this feature, just recompiled When it can join the My configured to Apache1.3.17 + Php4.0.4pl1, PHP for the Apache module, re-linux compiled by Netscape Navigator4.7 can test (which have proved irrelevant and browser).
An inter-session is not only the use of the window, even if you opened a Cookie, when you have a window of a legitimate session id (recorded in the session cookie, not in the URL), and then open a new window into the same page , You will re-possession of a new session id, and a window with a Hubuyingxiang. Inter-window to use the same session id can only specified in the URL after the session id, that is if you put a session id's Copy the URL of the window, opened the window in the paste, or use the same. Know that the session id of this principle to achieve inter-session window is not difficult, Cookie can combine with the session, the first in the current legal session id, then it recorded in Cookie, in the other window to read Cookie can get the current Session id. realization I remember that in phpuser on an article specifically discussed. phpsu提供的php教程
The final say:
① often been asked, "Why did you write copy the code, they will go wrong, you too……", then used an error to see:
Warning: open (/ tmpsess_eca1da208748db2e9c6bec1fccc182b4, O_RDWR) failed: m (2) in c: / www/test1.php on line 2
In fact, is his own problem: session kept the path / tmp does not exist. There are two ways: First, in the root directory (usually C:) built a group called tmp directory and the other is to amend php.ini file
session.save_path = / tmp;
The / tmp directory with absolute path specify a directory (of course there must be), such as in my php.ini
session.save_path = G: PHPtempsession;
② there is a case of an error message as follows:
Warning: Cannot send session cache limiter - headers already sent (output started at
c: / www/test1.php: 1) in c: / www/test1.php on line 2
This is because you use session_start () before the output data to the client, for instance, Html tags, text and even spaces will not work, so the best in the first sentence on the procedures used session_start ().
TITLE:Session must depend on whether the Cookie