Re: Session problem

From: Date: Thu, 13 Jul 2000 03:01:19 +0000
Subject: Re: Session problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-6369@lists.php.net to get a copy of this message
When trying your site, the first URL is http://216.235.251.8/login.phtml?SID Now, since you have the if ($login) clause, you don't have a session_start() for your first run, and therefore no SID. Take out ALL of the if($login) stuff, and minimize your code until you get something that works. You'll have to strip it down (even further) since no one else seems to have this problem. Drill down, layer by layer. -Szii At 09:58 AM 7/12/00 -0400, Thomas Deliduka wrote: >I keep being told to read the manual and I have been reading the manual >exhaustively over and over, I don't see that I have done anything >differently than what the manual says. Except maybe the SID thing. > >That's an interesting point of view, but if cookies are off then wouldn't it >be the exactly the same thing to use SID or do PHPSESSID=<? echo >session_id(); ?> > >Is there no difference between the two? > >I don't know why setting it explicitly or doing the SID macro is any >different. And this doesn't, in my mind, explain why the session is created >and then the second post the session is re-created and only on the third >post it actually carries over. > >I have updated http://216.235.251.8/login.phtml anyway with the ><?= SID?> >anyway just to see what happens. I find that I get almost the same results. > >The first post I get it posting to login.phtml?SID (probably because the >session hasn't started so when I tell it to echo SID it just takes it as a >string) and it creates the session, no problem. Although cookies are turned >on in my browser the SID macro still is populated. > >The second post creates a new session and the SID macro is populated, the >posting is done to login.phtml?PHPSESSID=the-session-id > >with Nav on the Mac, it is until the 5th post that the session is actually >carried over for good. > >I have created a link to my PHP info so everything I have compiled into it >is listed. > >Also, Another question concerning the SID macro... > >If I have a URL which is something like this: > >filename.php?loginid=3954 > >And I want to put the SID macro in I have to put: > >filename.php?loginid=3954&<?=SID ?> > >which places a trailing "&" at the end of my URL if cookies are on. Doesn't >that cause a problem? Or more importantly if I had: > >filename.php?<?=SID ?>&loginid=3954 > >That would result in filename.php?&loginid=3954 if cookies were on. Does >this pose a problem as well? > >I found it interesting that on 7/12/00 12:33 AM Szii said: > >> I tried your page, and you should reread >> >> http://www.php.net/manual/ref.session.php >> >> Most importantly, >> >> --snip >> >> PHP is capable of doing this transparently when compiled with >> --enable-trans-sid. If you enable this option, relative URIs will be >> changed to contain the >> session id automatically. Alternatively, you can use >> the constant SID which is defined, if the client did not send the >> appropiate cookie. SID is either of the >> form session_name=session_id or is an empty string. >> >> The following example demonstrates how to register a >> variable, and how to link correctly to another page using SID. >> Example 1. Counting the number of hits of a single user >> >> 1 >> 2 <?php >> 3 session_register("count"); >> 4 $count++; >> 5 ?> >> 6 >> 7 Hello visitor, you have seen this page <? echo >> $count; ?> times.<p> >> 8 >> 9 <php? >> 10 # the <?=SID?> is necessary to preserve the >> session id >> 11 # in the case that the user has disabled cookies >> 12 ?> >> 13 >> 14 To continue, <A >> HREF="nextpage.php?<?=SID?>">click here</A> >> 15 >> >> --end snip >> >> >> Your code shows >> >> >> --snip >> <FORM METHOD=POST ACTION="login.phtml?PHPSESSID=<? echo session_id(); >> ?>"> >> --end snip >> >> Hmm...you're setting PHPSESSID explicitly and the example from www.php.net >> shows that your line >> SHOULD be... >> >> <FORM METHOD=POST ACTION="login.phtml?<?=SID?>"> >> or >> <FORM METHOD=POST ACTION="login.phtml?<?echo session_id();?>"> >> >> >> Ya might try setting it that way and see if you get the correct id's. > >-- > >Thomas Deliduka >IT Manager > ------------------------- >New Eve Media >The Solution To Your Internet Angst >http://www.neweve.com/ > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.general (#6369) next »