Users have to login and logout twice, why?

Reply

Join Date: Jul 2009
Posts: 20
Reputation: eantz is an unknown quantity at this point 
Solved Threads: 0
eantz eantz is offline Offline
Newbie Poster

Users have to login and logout twice, why?

 
0
  #1
Jul 15th, 2009
Hi..
I'm newbie here..

I have a problem with my login and logout script..

Here is the login script:

  1. <?php
  2. $q = "SELECT * FROM members WHERE username='%s' AND password='%s'";
  3. $q = sprintf($q, $username, $password);
  4. $q = mysql_query($q);
  5. if (mysql_num_rows($q) > 0) {
  6. $_SESSION['id'] = $q[0]['id'];
  7. $IS_LOGGED_IN = true;
  8. }
  9. ?>

here is the logout script:

  1. <?php
  2. session_start();
  3. unset($_SESSION['userid']);
  4. session_destroy();
  5. $_SESSION = array();
  6. header('Location: index.php');
  7. ?>

and I have a variable which is called in every page that define some one logged in:

$IS_LOGGED_IN = (isset($_SESSION['userid'] && $_SESSION['userid'] !== '');
With that code, users have to login twice before he is in real login state. It happens to with logout.

Why?

Thank's for helping me..
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 1
Reputation: No Box is an unknown quantity at this point 
Solved Threads: 0
No Box No Box is offline Offline
Newbie Poster

Re: Users have to login and logout twice, why?

 
0
  #2
Aug 18th, 2009
Check all of your links to the other web pages. I had the same problem with the session resetting itself when I had the <a href="http://www.yoursite.com/page.php"> instead of <a href="page.php"> I set all of them the same way no mixing and matching them together to navigate through the page and it worked.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Users have to login and logout twice, why?

 
0
  #3
Aug 19th, 2009
Yes, Check all the links and conditions on your web page. may be some where else same working is happening.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 417 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC