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
    Regular Coder
    Join Date
    Feb 2006
    Posts
    138
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Help creating a login variable

    Need a little direction here.. Basically, what I'm trying to do is:

    1. Have people log in to my website using a login page with an ID# (which they already know>

    2. The ID# needs to be stored as a variable for use on the following page, where it will be included as a hidden field in a form the person will be submitting for inclusion in a MySQL DB

    3. This whole thing will be hosted on a kiosk, so I need two things to happen. The variable needs to be reset (cleared, whatever..) on a certain inactivity timeout period, or at the completion of the session (which will be activited by clicking an "exit" button).


    I'm pretty well versed in PHP, HTML, etc., it's more a matter of figuring out the best way to store this variable for later use, and then having it reset at a certain point so the next user can start from scratch. Any help in the right direction is greatly appreciated!!!

  • #2
    Regular Coder goughy000's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    415
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sessions

    http://uk2.php.net/manual/en/function.session-start.php

    example code..

    index.php
    PHP Code:
    <?php
    // Start session before any output!
    session_start();

    // Define session variables
    $_SESSION[colour] = "red";
    $_SESSION[object] = "book";

    ?>

    <html>
    <body>
    <a href="page2.php">GO!</a>
    </body>
    </html>
    page2.php
    PHP Code:
    <?php

    // Start, well "resume", the session (before any output)
    session_start();

    // Session variables not defined on this page but carried over from last page
    echo "oh look a $_SESSION[colour] $_SESSION[object]";

    ?>
    And to end the session....
    PHP Code:
    <?php
    // Load session
    session_start();

    // Kill session
    session_destroy();
    ?>
    EDIT:
    Also adding to that...
    http://uk2.php.net/manual/en/functio...che-expire.php

    Calling this code BEFORE session_start(); you can set how long the session should last (in minutes) before being ended... I think you would either be able to put this on every page to update it to say.. 30mins.. every new page, or just on the first page. But you might have to call it on every page, never used it before

    PHP Code:
    session_cache_expire(30); 
    Last edited by goughy000; 02-18-2006 at 10:15 AM.


  •  

    Posting Permissions

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