Portal Home > Knowledgebase > Articles Database > PHP Logout - Logout not working on Vista


PHP Logout - Logout not working on Vista




Posted by HostRefugee-Vince, 05-10-2007, 06:34 PM
Hi Everyone, I have created a simple script to handle logging in and out of an admin area. Everything was good, until I start to show it off to a design client. While trying to logout of the software, the script wouldn't log out. Perhaps it's a cookie issue unique to Vista? Anyhow, both the login and logout parts of the code are included below. If anyone notices something that may affect Vista users, I would highly appreciate it if you could point it out. This is not the full code, so if it is missing a curly... That's not the problem!

Posted by HostRefugee-Vince, 05-10-2007, 06:37 PM
Might be helpful if I include the important code in the config.php

Posted by Xenatino, 05-10-2007, 07:33 PM
After the Meta refresh, try running to see what the actual contents of the cookies are.

Posted by sasha, 05-10-2007, 07:45 PM
Heh, that looks so messy Here are some drunk comments - excuse my hiccups. 1. do not include (config.php) if it is important do require (config.php) 2. do not bother with cookies. PHP sessions are much prettier to use. if (login form submited) { $_SESSION['luser'] = new Luser (); if ($_SESSION['luser']->login ($_POST['username'] , $_POST['password'] ) ){ // user is logged in }else{ // login attempt failed } // and later if ($_SESSION['luser']->user_id ) { // this user is logged in , we can show him secrets }else{ // no secrets for you, redirect to login form } // and even later if (logout form submited ) { $_SESSION['luser'] = new Luser (); // or $_SESSION['luser']->logout (); } only part you are missing there would be class Luser class Luser{ function Luser(){ $this->user_id = ''; $this->rights= array (); } function login ($username, $password) { $query = " SELECT id, ... where usernaeme and password ... " $res = run db query ; if ($r = get assoc result row ($res) ) { $this->user_id = result_row [id ] ..... // you could populate rights array here in some way $his->rights = ..... ; } } function logout (){ $this->user_id = '' ; // you can kill another vars you set for this object here // re-initiating object might be easier } // you can extend this to handle more stuff function create (...) { // make new user account } ..... }

Posted by ak7861, 05-10-2007, 11:23 PM
Check and see if you have enabled cache in your php code. This happened to me before, and I got rid of it by using an alternative to cache.. sessions.

Posted by stuffradio, 05-11-2007, 12:00 AM
Vista is not something that requires special code for lol, it would be something in your code if it wasn't something that one of the above posted

Posted by ak7861, 05-11-2007, 12:08 AM
No one said special code. Every browser and operating system can deal with cache differently.

Posted by Jatinder, 05-11-2007, 01:08 AM
Use this to unset the cookies:

Posted by orbitz, 05-11-2007, 11:32 AM
another thing I've noticed: Why would you want to store these two info to cookie and use it for authentication? Isn't this a security risk to your application?

Posted by HostRefugee-Vince, 05-11-2007, 11:55 AM
Thanks Sasha, I am going to switch it over to sessions rather than cookies. Thanks everyone else for their insight!



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
CHMOD 755 or 777 (Views: 659)