SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: lost of my Session var
-
Aug 24, 2007, 06:05 #1
lost of my Session var
Hi there I want to store the language choosen by the user in $_session['lang']
This exactually works fine but i now i have a form in one of my pages, this form doesn't posts/gets the language with the submit, which results that the $_session['lang'] is overwritten. Can anyone help me out here?
Everypage has this code included maybe im doing it all wrong?
Code PHP:if(!isset($_GET['lang']) && !isset($_SESSION['lang'])){ $Currentlan=GetMainLanguage(); session_start(); $_SESSION['lang']=$Currentlan; } if(isset($_GET['lang'])){ $Currentlan=$_GET['lang']; session_start(); $_SESSION['lang']=$Currentlan; }
-
Aug 24, 2007, 06:32 #2
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
put session_start() at the top of every page, not in the middle of a function.
Then, replace the above functions with:
PHP Code:if(!isset($_GET['lang']) && !isset($_SESSION['lang'])){
$Currentlan=GetMainLanguage();
$_SESSION['lang']=$Currentlan;
}else if(isset($_GET['lang'])){
$Currentlan=$_GET['lang'];
$_SESSION['lang']=$Currentlan;
}
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Aug 24, 2007, 06:36 #3
that's it!
It worked Thanks a lot!
Bookmarks