SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Sessions in PHP

  1. #1
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sessions in PHP

    Hey

    Assuming you use session_start();

    -- how long do these last? And I would like to create a page/function/button that people hit to logout and therefore kill the session.

    Would I add this in the same include file I am using to log people in, or would it be a separate one totally.

    Help please!
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right.

    To kill a session put something like this in a script :
    PHP Code:
    <?php

    session_start
    ();

    session_destroy();

    echo 
    "You have been logged out";

    ?>
    The life of a session depends on a setting in the php.ini file. You can extend this using a htacces file if you are using Apache.

    Sean

  3. #3
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks...

    BUT...

    Do I put this is in a whole new .php file or what?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could put it in a file called logout.php and then provide a link to log out :

    <a href="logout.php">Log out</a>

    Sean

  5. #5
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got ya.

    cheers for the help!
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky


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
  •