From:             [EMAIL PROTECTED]
Operating system: Red Hat 6.1
PHP version:      4.0.6
PHP Bug Type:     Session related
Bug description:  new session ID with each session_start()

I am making a desperate cry. I seem to be the only one on 
the face of the planet who has this problem. Whenever I 
post to the PHP-general group the discussion goes on and 
then ends up with someone writing me saying, "gee man, I 
don't know".

I put in a bug report about this back at php 4.0.1pl2 and 
it was concluded that I was using the POST value instead of 
GET in the form. That bug is this: 
http://bugs.php.net/bug.php?id=5360

Now, in PHP 4.0.6 it still plagues me and there's a program 
I need to run on my server and it won't run because of my 
session problem.

Okay, so this is the deal in a nutshell.  With each 
subsequent call to 'session_start()' instead of picking up 
the existing session, it creates a new PHPID.  This happens 
whether I have the sessionID in a cookie or passed via a 
variable (VIA THE QUERYSTRING).  I have included code for 
two files that I use as a demonstration so you can check 
the code, and I can send you to a website where you can see 
it in action..

Code:

filename: index.php
----------
<?
error_reporting(E_ALL);
session_start();

$var1 = "My var 1";
$var2 = "My var 2";

session_register("var1");
session_register("var2");

?><HTML>
<HEAD>
<TITLE>Session Page 1</TITLE>
</HEAD>

<BODY BGCOLOR=#FFFFFF>

PHPSESSID: <? echo session_id(); ?><BR>
Var1: <? echo $var1; ?><BR>
Var2: <? echo $var2; ?><BR>

<FORM ACTION="index2.php" METHOD="POST">
Passing sessid: <INPUT TYPE=TEXT VALUE="<? echo 
session_id(); ?>" SIZE=40 NAME="PHPSESSID"><BR>
VAR 3: <INPUT TYPE=TEXT VALUE="My Var 3" NAME="myvar3"> 
<INPUT TYPE=SUBMIT VALUE="go"><BR>
</FORM>
<BR>
<A HREF="index2.php?<?=SID?>">Try this link</A>
</BODY>
</HTML>
----------

filename: index2.php
----------
<?
error_reporting(E_ALL);
session_start();                // start session
session_register("var3");      // register var 3 session 
variable

$var3 = $myvar3;
?><HTML>
<HEAD>
<TITLE>Session Page 2</TITLE>
</HEAD>

<BODY BGCOLOR=#FFFFFF>

PHPSESSID: <? echo session_id(); ?><BR>
Var1: <? echo $var1; ?><BR>
Var2: <? echo $var2; ?><BR>
VAR3: <? echo $var3; ?><BR>

</BODY>
</HTML>
----------

in action: http://www.fromtheduke.com/session/index.php

I have noticed with other pages that I have tried this on 
this same server that the session_start() will create a new 
session ID three times, on the third one, it 'sticks' and 
stays with me the rest of the time.

here is my php.ini file which shows my session variable 
options:
------------
[Session]
session.save_handler      = files   ; handler used to 
store/retrieve data
session.save_path         = /tmp    ; argument passed to 
save_handler
                                    ; in the case of files, 
this is the
                                    ; path where data files 
are stored
session.use_cookies       = 1       ; whether to use 
cookies
session.name              = PHPSESSID
                                    ; name of the session
                                    ; is used as cookie 
name
session.auto_start        = 0       ; initialize session on 
request startup
session.cookie_lifetime   = 0    ; lifetime in seconds of 
cookie
                                    ; or if 0, until 
browser is restarted
session.use_trans_sid     = 1
session.cookie_path       = /       ; the path the cookie 
is valid for
session.cookie_domain     =         ; the domain the cookie 
is valid for
session.serialize_handler = php     ; handler used to 
serialize data
                                    ; php is the standard 
serializer of PHP
session.gc_probability    = 1       ; percentual 
probability that the
                                    ; 'garbage collection' 
process is started
                                    ; on every session 
initialization
session.gc_maxlifetime    = 1440    ; after this number of 
seconds, stored
                                    ; data will be seen as 
'garbage' and
                                    ; cleaned up by the gc 
process
session.referer_check     = 0        ; check HTTP Referer 
to invalidate
                                    ; externally stored 
URLs containing ids
session.entropy_length    = 0       ; how many bytes to 
read from the file
session.entropy_file      =         ; specified here to 
create the session id
; session.entropy_length    = 16
; session.entropy_file      = /dev/urandom
session.cache_limiter     = nocache ; set to 
{nocache,private,public} to
                                    ; determine HTTP 
caching aspects
session.cache_expire      = 180     ; document expires 
after n minutes
------------

I am at my wit's end. I NEED HELP. Please please help me oh 
PHP programming gods. I have no where else to turn.

This problem happens with Macintosh and Windows Browsers, 
Netscape or internet Explorer, it doesn't matter.

My server info: http://stjohn.neweve.com/phpinfo.phtml

I'm happy to give help to anyone that will work with me.
-- 
Edit bug report at: http://bugs.php.net/?id=13841&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to