Re: losing session variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 "<br>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"<br>Username : ".$_SESSION['username'];
>> echo "<br>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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux