Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Session destory error

Session destory error

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
questionphphtmldatabasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SRJ92
    wrote on last edited by
    #1

    hi, i have created a member log in system which will change a page which is included on the homepage.... Ok, now when i log out it destroys the session fine but then i get this error "Notice: Undefined index: logged in ttab.php on line 4", how do i get rid of the error because on other pages it seems to go away ... Code for file which displays depending on session ... (ttab.php)

    <html><style>div{font-family:Arial;}</style><body>
    <?php
    session_start();
    if (!($_SESSION['logged']== true))
    {
    echo"<a href='memlogin.php?msg=0' id='flink'><div>Register/Log In</div></a>";
    }else{
    $name = $_SESSION['user'];
    echo"Welcome $name, &nbsp<a href='account.php' id='flink'>Account Options</a>&nbsp|&nbsp<a href='ref/logout.php'id='flink'>Log Out</a>";
    }
    ?>
    </body></html>

    Process that the log out does ... (logout.php)

    //Logout process
    session_start();
    session_destroy();
    header("location: ../index.php");

    G 1 Reply Last reply
    0
    • S SRJ92

      hi, i have created a member log in system which will change a page which is included on the homepage.... Ok, now when i log out it destroys the session fine but then i get this error "Notice: Undefined index: logged in ttab.php on line 4", how do i get rid of the error because on other pages it seems to go away ... Code for file which displays depending on session ... (ttab.php)

      <html><style>div{font-family:Arial;}</style><body>
      <?php
      session_start();
      if (!($_SESSION['logged']== true))
      {
      echo"<a href='memlogin.php?msg=0' id='flink'><div>Register/Log In</div></a>";
      }else{
      $name = $_SESSION['user'];
      echo"Welcome $name, &nbsp<a href='account.php' id='flink'>Account Options</a>&nbsp|&nbsp<a href='ref/logout.php'id='flink'>Log Out</a>";
      }
      ?>
      </body></html>

      Process that the log out does ... (logout.php)

      //Logout process
      session_start();
      session_destroy();
      header("location: ../index.php");

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      The "undefined index" message is telling you that there is no value with the key 'logged' in $_SESSION. Try changing your test to this:

      if (!(isset($_SESSION['logged']) && $_SESSION['logged']== true))

      The isset call will short-circuit the test if the 'logged' key is not found.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups