0

Hi..
I'm newbie here..

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

Here is the login script:

<?php
$q = "SELECT * FROM members WHERE username='%s' AND password='%s'";
$q = sprintf($q, $username, $password);
$q = mysql_query($q);
if (mysql_num_rows($q) > 0) {
$_SESSION['id'] = $q[0]['id'];
$IS_LOGGED_IN = true;
}
?>

here is the logout script:

<?php
session_start();
unset($_SESSION['userid']);
session_destroy();
$_SESSION = array();
header('Location: index.php');
?>

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..

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by BzzBee
0

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.

0

Yes, Check all the links and conditions on your web page. may be some where else same working is happening.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.