Re: Re: YA Session Problem

From: Date: Fri, 03 Aug 2001 15:18:22 +0000
Subject: Re: Re: YA Session Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61143@lists.php.net to get a copy of this message
On 8/3/2001 2:25 AM this was written: >> --------- file 1 ----------- > > What filename is this?... Index.php is the filename. >> <? >> >> session_start(); >> >> if (!isset($var1)) { >> session_register("var1"); >> session_register("var2"); >> header("location: index.php"); > > That should be Location with a capital 'L'. It matters. I have probably 400+ scripts under my belt. I would say a good 150 of those pages use header("location: ..") without it being capitalized. They work perfectly fine. What is the difference? > If you are using Cookies for sessions > I am using cookies. >, then this page is sending both Cookie > headers and Location headers in the same exchange, since you've got > session_start() (and/or session_register()). > > You can't do that. I can't start the session for the first time and register a variable? Isn't that what most people do? > Ooooooh. If this file *IS* index.php, you've got BIG logic problems... I see what you mean concerning the issset($var1) this code I have here is almost identically copied from an install script that was created by the Mambo OpenSource project. And like I said, on my Mac, it would redirect about 5 times before the browser decided it was in a loop and stopped. ... Okay, I have re-written my code for index.php to say this: (see below for analysis) ------------ <? session_start(); session_register("var1"); session_register("var2"); $var1 = "My var 1"; $var2 = "My var 2"; ?><HTML> <HEAD> <TITLE>Session Page 1</TITLE> </HEAD> <BODY BGCOLOR=#FFFFFF> PHPSESSID: <? echo $PHPSESSID; ?><BR> Var1: <? echo $var1; ?><BR> Var2: <? echo $var2; ?><BR> <FORM ACTION="index2.php" METHOD="POST"> VAR 3: <INPUT TYPE=TEXT VALUE="My Var 3" NAME="myvar3"> <INPUT TYPE=SUBMIT VALUE="go"><BR> </FORM> </BODY> </HTML> ------------ IE 5 for the Mac: When I hit ths page first (real page at: http://www.fromthduke.com/session/) the echo of $PHPSESSID does not show up; it's not echoed to the screen. The echo of var 1 and var 2 work fine. Then the form, of course is there. So, if $PHPSESSID isn't there, that leads me to believe that the cookie was not set. So, I go check (making sure that before this test the cookie was not present before.) Low and behold, the cookie is there in my cookies list and it's got a value. Then I click submit... The PHPSESSID is echoed as the same value that is in the cookie: d5184618d558ffe038a28e9e1adbdf26 Myvar 1 and 2 are blank Myvar 3 is there. (posted from previous form) I look on the server, there is an additional session file on the server: sess_e78835fbbf62c0ddc77d46b6ff95e0cc It contains the Myvar 3 information. Okay, perhaps it's a Mac thing, so I went to IE 5 for the PC: Same results. Well, perhaps it's a IE thing... Let's try netscape on both platforms: Same Results. So, it's not a browser thing, it must be a server thing. Perhaps the way I have Sessions setup in the .ini file? I think I have all the defaults, but here is the section echoed: ---------- [Session] session.save_handler = files session.save_path = /tmp session.use_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 3600 session.cookie_path = / session.cookie_domain = session.serialize_handler = php session.gc_probability = 1 session.gc_maxlifetime = 1440 session.referer_check = 0 session.entropy_length = 0 session.entropy_file = ; session.entropy_length = 16 ; session.entropy_file = /dev/urandom session.cache_limiter = nocache session.cache_expire = 180 ---------- Perhaps it's the 'nocache' directive? Now I have given you all I can without giving you root access to my server. Here is the location of my test (as above): http://www.fromtheduke.com/session/ -- Thomas Deliduka IT Manager ------------------------- New Eve Media The Solution To Your Internet Angst http://www.neweve.com/

« previous php.general (#61143) next »