#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    31
    Rep Power
    16

    cant delete cookies random errors


    Hi there!

    i have read all posts on deleting cookies here, but it still doesnt work...

    my login script sets the following cookies
    PHP Code:
    $checksum=md5($_POST['pass']);
    srand ((double)microtime()*1000000);
    $mysidmd5(uniqid(rand()));
    setcookie (cid,$return_login,time()+3600);
    session_id($mysid);
    session_start();
    $_SESSION['id']=$return_login;
    $_SESSION['ip']=$_SERVER['REMOTE_ADDR'];
    setcookie (cmd5,$checksum,time()+3600);
    echo 
    "Login erfolgreich! Bitte Warten!";
    mysql_close();
    echo 
    "<meta http-equiv=\"refresh\" content=\"2; URL=index.php\">"
    i previously had errors onmy localhost that sometimes only one cookie got set, or both werent set or it worked and i never changed anything...setting the cookies works on my internet webserver without a problem though...
    basically i only use sessions for logging in and everything, the cookies are only set to stay logged in when you come back and visit the site...
    my code to check that is the following

    PHP Code:
    if (isset($_COOKIE['cid']) && isset($_COOKIE['cmd5']))
    {
                    echo 
    "ja";
        
    $cmd5=$_COOKIE['cmd5'];
        
    $cid=$_COOKIE['cid'];
        
    $query "SELECT pchecksum FROM user WHERE id='$cid'";
        
    $result mysql_query($query) OR die(mysql_error());
            
    $pcheck mysql_fetch_object($result);
            
    mysql_free_result($result);
            if (
    $cmd5==$pcheck->pchecksum)
            {
                
    $_SESSION['id']=$cid;    
            } else
                {
                    
    session_destroy();
                }
        

    this checks if the cookies are set and if they are set SESSION['id'] to the id stored in the cookie (a pass checksum check for security reasons)...

    now my script to delete the cookies, with randomly works...yesterday it all worked fine, today it didnt work on both of my machines, then suddenly worked on one of my pcs but on my laptop it still doesnt, but worked on all pcs yesterday...
    very confusing :/

    PHP Code:
    session_start();
    session_destroy();
    setcookie ("cid","$return_login",time() - 3600);
    setcookie ("cmd5","$checksum",time() - 3600);

    echo 
    "Logout erfolgreich! Bitte Warten!";
    echo 
    "<meta http-equiv=\"refresh\" content=\"2; URL=index.php\">"
    this should kill the session and all the cookies i use, but sometimes it doesnt, sometimes it does...i dont get it :/
    hope anyone can help me out

    thanx in advance,
    Arne
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    31
    Rep Power
    16
    i am afraid some lines position got messed up
    sorry for that
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    31
    Rep Power
    16
    hmz
    i like this forum so much, but why I never get replies to my questions :/
    am i doing something wrong ?

IMN logo majestic logo threadwatch logo seochat tools logo