RE: [PHP] session problem
| From: | Ford, Mike [LSS] | Date: | Wed, 04 Feb 2004 13:42:46 +0000 |
| Subject: | RE: [PHP] session problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176789@lists.php.net to get a copy of this message | ||
On 04 February 2004 12:59, marc serra contributed these pearls of wisdom:
> Hi,
>
>
>
> I'm working on a multi-langage website and i got problem with
> a fonction
> which destroy my session :-(
>
>
>
> I got a file which change my langage like this :
>
>
>
> /********************************************/
>
> session_start();
>
>
>
> if ($_POST['langue']=="us")
>
> $_SESSION['language']="us";
>
> else if ($_POST['langue']=="fr")
>
> $_SESSION['language']="fr";
>
>
>
> header("Location:
>
> http://".$_SERVER['HTTP_HOST'].$_POST['page_name']);
>
>
> /*********************************************/
If you rely on URL rewriting to transmit your session ID, this won't work for header redirects,
so you need to manually include the SID value. In any case, this is good defensive programming (in
case that configuration parameter ever gets changed!). So your redirect should look like:
header("Location: http://".$_SERVER['HTTP_HOST'].$_POST['page_name'].'?'.SID);
Cheers!
Mike
--
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211