SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast ethe's Avatar
    Join Date
    Oct 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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;
    }

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    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;

    That should work
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Enthusiast ethe's Avatar
    Join Date
    Oct 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    that's it!

    It worked Thanks a lot!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •