Question about sessions
| From: | Radu Filip | Date: | Tue, 12 Sep 2000 17:22:03 +0000 |
| Subject: | Question about sessions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16391@lists.php.net to get a copy of this message | ||
Hi!
I have a site that must use sessions. I want to create the session first
time I visit a page and then to preserve the PHPSESSIONID using cookies.
My php is compiled with --enable-register_globals and --disable-trans-sid
My browser if configured to warn me everytime a cookie is going to be
setup.
All the pages in my site include the following code:
1 global $HTTP_COOKIE_VARS;
2 if (isset($HTTP_COOKIE_VARS["PHPSESSID"]))
3 {
4 session_id($HTTP_COOKIE_VARS["PHPSESSID"]);
5 session_start();
6 }
7 else
8 {
9 session_start();
10 setcookie("PHPSESSID", session_id());
11 }
Unfortunatelly, is seems every time I request a page, browser tries to
setup another cookie (for the same PHPSESSID). More, first time it aske
twice. Please show me where is my mistake?
I have php4.0.1pl2/RH 6.2/Kernel 2.2.14/Apache 1.3.12
Thx,
Socrate
--
Radu Filip
Network Administrator @CCTI | tuiasi.ro
radu@tuiasi.ro ccti@tuiasi.ro
http://socrate.tuiasi.ro/ http://www.ccti.tuiasi.ro/