SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict Huscy's Avatar
    Join Date
    Jul 2002
    Location
    Newcastle, UK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cant get a logout thingy to work :'(

    OK, rather than post all my code (a lot) i'll just try to explain the problem, maybe my logic is screwed, im trying to allow people to log out of my system, they can login, and i store 2 variables in a cookie when they do (their username, and whether theyve logged in or not) as here:

    PHP Code:
            $allow_access "yes";
            
    $username $_POST['l_username'];
            
    setcookie ("logged_in[0]"$allow_access,time()+3600);
            
    setcookie ("logged_in[1]"$username,time()+3600);
            echo(
    "You have successfully logged in, please wait");
            echo(
    "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2;URL=index.php\">"); 
    now when i try to let them log out using ...

    PHP Code:
    if($_GET['lo'])
    {
    setcookie ("logged_in[0]""",time()-3600);
    setcookie ("logged_in[1]""",time()-3600);
    echo(
    "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=$_SERVER['PHP_SELF']?\">");


    it doesnt alter the cookie contents - can anyone help ?

  2. #2
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you might try the unset command. I know in sessions I always unset the variables before i destroy the session.
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."

  3. #3
    SitePoint Addict Huscy's Avatar
    Join Date
    Jul 2002
    Location
    Newcastle, UK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesnt work :/

  4. #4
    SitePoint Zealot LiamW's Avatar
    Join Date
    Mar 2003
    Location
    Hamilton, Ontario
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cookies must be deleted with the same parameters as they were set with. Make the time +3600 not -3600.

  5. #5
    SitePoint Addict Huscy's Avatar
    Join Date
    Jul 2002
    Location
    Newcastle, UK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still dont work :/

  6. #6
    SitePoint Zealot LiamW's Avatar
    Join Date
    Mar 2003
    Location
    Hamilton, Ontario
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like you had it correct the first time when you had - 3600. I read a bit about setcookie and it does say to make the time in the past when deleting it.
    I don't use cookies a lot myself so I don't know setcookie that well.

    The problem might be that you are refreshing the page instead of forwarding them somewhere else.


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
  •