Re: [PHP] losing session variable
On Sun, May 6, 2007 11:29 am, Alain Roger wrote: > Hi, > > I have the following code : > > session_start(); >> $_SESSION['username']=$myusername; >> $_SESSION['Localization'] = $lang; Add this: session_write_close(); before you do header re-direct. >> header("Location: >> https://".$_SERVER['SERVER_NAME'].$path_adm_files."/modules/welcome/welcome.php"); >> > > if i check before header command what is the value of > $_SESSION['username'], > i get the right value. > however, if i place on the first line of welcome.php file the > following code > : > > echo "1. Before session"; session_start() sends out a Cookie (depending on php.ini settings) and you can't send a cookie header after content body. http://php.net/session_start >> session_start(); >> echo"Username : ".$_SESSION['username']; >> echo "2. After session"; >> > > i get empty value for this session variable. > How is it possible ? > > in my first code piece, if i use localhost instead of > $_SERVER['SERVER_NAME'], it creates a session file in my temporary > folder as > it should be > I'm confused now :-( > > thanks a lot for your help. > -- > Alain > > Windows XP SP2 > PostgreSQL 8.1.4 > Apache 2.2.4 > PHP 5.2.1 > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] losing session variable
On 5/6/07, Alain Roger <[EMAIL PROTECTED]> wrote: if i check before header command what is the value of $_SESSION['username'], i get the right value. however, if i place on the first line of welcome.php file the following code : echo "1. Before session"; > session_start(); > echo"Username : ".$_SESSION['username']; > echo "2. After session"; > i get empty value for this session variable. How is it possible ? You have to execute the session_start method before any data have been sent to the client. You are sending data to the browser with 'echo "1. Befor Session";' -- Saludos Oscar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] losing session variable
Hi, I have the following code : session_start(); $_SESSION['username']=$myusername; $_SESSION['Localization'] = $lang; header("Location: https://".$_SERVER['SERVER_NAME'].$path_adm_files."/modules/welcome/welcome.php"); if i check before header command what is the value of $_SESSION['username'], i get the right value. however, if i place on the first line of welcome.php file the following code : echo "1. Before session"; session_start(); echo"Username : ".$_SESSION['username']; echo "2. After session"; i get empty value for this session variable. How is it possible ? in my first code piece, if i use localhost instead of $_SERVER['SERVER_NAME'], it creates a session file in my temporary folder as it should be I'm confused now :-( thanks a lot for your help. -- Alain Windows XP SP2 PostgreSQL 8.1.4 Apache 2.2.4 PHP 5.2.1
Re: [PHP] Losing Session Variable in IE Only?
I was doing some stupid shit like doing a session_unregister() on my variables, then later, after successful login, redoing a session_register(). When I made a separate logoff.php page to unregister the variable, then a redirect back to index.php to allow users to login again, everything worked fine. Very odd the way that it only messed up in IE6 though Thanks anyway for the tips. "Pierre-Yves" <[EMAIL PROTECTED]> wrote in message news:007201c1686b$6db59290$0100a8c0@py... > Hello, > > I had the exact same problem as you last week with IE 6.0 > > I was building my session on a domain but the variable used to build > the session were coming from another domain. > > I was using a file on my server associated ususally with another domain and > that file had a session_start() > > I do not know what of these 2 thing caused the problem because I change both > at the same time and it worked! > (I move the login form and didn't use the file...) > > It seems to be a problem with the default security settings of IE 6.0 > because when I was doing: > Tools/Internet Options/Privacy/Advanced/and select "Override automatic > cookie handling" > everything worked! > > hope it help, > py > > > > > > - Original Message - > From: "Herb Wiser" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, November 08, 2001 9:50 AM > Subject: [PHP] Losing Session Variable in IE Only? > > > > I am having the strangest problem and I'm not sure there is anybody on > this > > planet smart enough to figure it out > > > > I have a PHP application that I was running and testing under an existing > > URL, but by adding a port number to go to a different directory. > > > > Like this, http://www.investmentteams.com: > > > > It worked fine. I registered a domain name for it, got DNS set up, went > to > > the index.php page, did the login, but then when it transferred to the > next > > page, all the session variables were gone and this really makes the whole > > thing unusable. > > > > Here are the extenuating circumstances: > > > > It works fine in Netscape. > > It works fine in IE 5-point-something at work. > > Other websites using session variables (like www.investmentteams.com) work > > fine in IE6 at home. > > > > Oddly enough, the new URL is www.problemrpts.com , but if I cannot login I > > cannot enter a problem report > > > > Any guesses on this one? > > > > TIA > > > > > > > > -- > > PHP General 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] > > > -- PHP General 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]