Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to clear the data inside session variables?

    guys, how am i going to clear data inside session variables?
    in every page, i put a

    session.start();

    so i will be able to access the data that I stored inside the session variables.
    Now what I want to have a "RESET" function (button, link, etc) that will
    clear the data inside the session variables.

    I tried using a "RESET" link inside "home.php"
    <a href = "reset.php">RESET</a>

    inside "reset.php"..
    <?php
    session.close();
    header('home.php'); // this is the page where I initialize the session
    ?>

    inside "home.php"..
    <?php
    session.start();
    .. // some code where I store data inside the session
    ?>
    <a href = "reset.php">RESET</a> // reset link

    What do you think guys? I closed the session and started it again? I should get a session different from the previous one, right?

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    foreach($_SESSION as $key=>var)
    {
    unset($_SESSION[$key]);
    }

    ALSO, it is session_start and session_close. Underscore, not a period.


  •  

    Posting Permissions

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