Session expires

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • joapalmer
    New Member
    • Apr 2008
    • 1

    #1

    Session expires

    I have a strange problem. Having a site with multiple pages in PHP, all pages begins with this code:

    [PHP]<?php session_start() ;

    if (isset($_GET['lang'])) {
    if ($_GET['lang'] == "en") $_SESSION['lang'] = "en";
    if ($_GET['lang'] == "sv") $_SESSION['lang'] = "sv";
    if ($_GET['lang'] == "fi") $_SESSION['lang'] = "fi";
    }

    if (isset($_SESSIO N['lang'])) {
    $lang = $_SESSION['lang'];
    }

    ?>[/PHP]

    No other code refers to session* or $_SESSION - just $lang is involved.

    All pages exept index.php works (ie session is preserved) but when I exit index.php the session is renewed. What can be the issue?

    Thanks for any help - very appreciated! regards Joa
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    How do you 'exit' index.php? By closing the browser? How?
    And you are sure no unset of $_SESSION=''is anywhere in your code?

    If all negative, show the code from the first setting of the $_SESSION array and the script that is supposed to handle this $_SESSION['lang'] field (and does not find it).

    Ronald

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      Can you post some of your index code? The header part would be good.

      After you have run a page, what happens when you go back to the index page? Does it work then?

      Comment

      Working...