SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member edpudol's Avatar
    Join Date
    Oct 2004
    Location
    philippines
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session variable problem

    I use the following code to check if member of my site are logon on their account it works... but when accidentally I and my friend logon.. at the same time. I get a very rear error.. why does when I click the backbutton of my browser his information appear and my on my browser... so what happen is that I am login as him not any more my user name.

    this is my code:


    $auth = false;
    session_start();
    if(!isset($_SESSION['username']) && !isset($_SESSION['password'])){
    if($username!="" && $password!=""){
    $_SESSION['username'] = $username;
    $_SESSION['password'] = $password;
    }else{
    echo "<script language = JavaScript>
    location.href='index.php';
    </script>";
    exit;
    }
    What is the problem with my script...

  2. #2
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well instead of using JS, you should do

    PHP Code:
    else{
    header('Location: index.php');

    also you seem to be missing a '}' for the first if (unless i am just missing it)

  3. #3
    SitePoint Member edpudol's Avatar
    Join Date
    Oct 2004
    Location
    philippines
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes } is not included in the example above but on the script it included... If I use the header function I got error always...

    Does session variable stored on client pc or in the server.. I really confuse why.. that if 2 or member logon together at the same time it will ramble their username.. but if member is logon alone script going smoth

    thanks

  4. #4
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Chicago, IL
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The session variable is a cookie, so it is stored on the users PC.

  5. #5
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some logic in your code is not right somewhere, I had the same problem once. We probably need to see the whole script to be able to help you.


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
  •