Results 1 to 1 of 1

Thread: PHP Sessions

  1. #1
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default PHP Sessions

    Hey Guys...
    Im Working On Multiple projects at once With My Server.
    this Evening I made an entire set of login/register scripts with encrypted passwords. and i Have a Question About Sessions.
    heres My logon Script... Fell Free to Point out Any Flaws.
    But What im Trying to do is create A script to destroy the sessions and log out.
    PHP Code:
    <?php require "connect.php"
    echo 'Loging on.\n\r';
    $user $_POST[post_user];
    $password md5($_POST[post_pass]);

    $userInfo mysql_query("SELECT * FROM `login` where `user`=`user-$user-`");
    if (!
    mysql_num_rows($userInfo)) {echo 'No such user!';}
    else    {
        
    $q mysql_fetch_array($userInfo);
        if (
    $password != $q[password]) {echo 'wrong password';}
        else    {
            
    session_start();
            
    $_SESSION['user'] = $user ;
            
    $_SESSION['pass'] = $password];
            
    $_SESSION['time'] = time();
            
    header("Location: $welcome_page");
            };
        };
    ?>
    The $welcome_page and mysql connect are in connect.php

    thanks in advance.

    Never Mind. decided to just null the values instead of destroying the sessions.

    PHP Code:
    <?php require "connect.php"
        
    $_SESSION['user'] = "";
        
    $_SESSION['pass'] = "";
        echo 
    "You have been Logged In For "time() - $_SESSION['time'] ." Seconds. /n/r
        <a href=\"
    $logout_to_page\">Continue.</a>" 
        
    $_SESSION['time'] = ""
    ?>
    Last edited by boxxertrumps; 01-11-2007 at 04:45 PM. Reason: Nevermind...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

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
  •