session Example

Discussion in 'PHP' started by KingCobra, Mar 2, 2009.

  1. #1
    I want to learn how to create php session ?
    Please teach me step by step easyly.

    Suppose,
    Create mysql table with 2 or more fields (your wish)
    Create a login php including session
    Create atleast 2 php for member/logged-in area
    Create logout php that will destroy session

    I want that, if a member close page without login, It will automaticall destry session and make logged out.
    I also need that if a user inactive for 20 minutes after login then it will destry session and ask for login again.

    No need more hatme code but just 1/2 line(s)

    Please teach me as short as you can. Thanks in advance
     
    KingCobra, Mar 2, 2009 IP
  2. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    #2
    serach the manuals about start_session()
     
    ankit_frenz, Mar 2, 2009 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    mwasif, Mar 2, 2009 IP
  4. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #4
    <?php
    session_start(); // Start a new session
    $_SESSION['ok'] = "Something here"; // assign value
    echo $_SESSION['ok']; // use our session variable
    ?>
    PHP:
     
    ActiveFrost, Mar 2, 2009 IP
  5. shiatsu

    shiatsu Peon

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    grab yourself a book or download some sample code and learn what it does. That's the best way. I believe no one here has the time to spoon feed you :)
     
    shiatsu, Mar 2, 2009 IP
  6. mdrobiul

    mdrobiul Peon

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    session destroy function can be used for user to logout without closing the browser. if user close browser without log out, session will automatically destroy. for timing seesion you must use cookie.
     
    mdrobiul, Mar 3, 2009 IP