Imran,
I wasn't completely clear on your question, but many of the problems you
will have with session_start() is when it is NOT the first line of code. You
might want to try "session_start() right after the opening "<?". If it is
not destroying your session code, it might be because you never started a
session. Either you forgot the code OR you think a session is started, but
it isn't actually started. I just did a bunch of work with logins and you
might want to try this. I don't think you need to check whether a user is
logged in or not on your "logout.php" page. If your code directs the user to
"logout.php", then it should automatically log off the user. Are you
receiving a specific error message?
Here are a few tips. Do several "echo" statement to make sure the value of
variables is what you think it is. Check for simple things such as
semicolons on previous lines above. Check for difference in upper-case and
lower-case.
<?php
session_start();
$loggedIn = $_SESSION['loggedIn'];
if ($loggedIn != TRUE) {
header("Location: index.php");
}
if ($loggedIn == TRUE) {
// put some code here.
}
On Thu, Apr 1, 2010 at 7:12 AM, Michael <[email protected]> wrote:
>
>
> <?
> // logout.php - destroys session and returns to login form
>
> // destroy all session variables
>
> session_name();
> session_start();
>
> // Unset all of the session variables.
> $_SESSION = array();
>
> // If it's desired to kill the session, also delete the session cookie.
> // Note: This will destroy the session, and not just the session data!
> if (isset($_COOKIE[session_name()])) {
> setcookie(session_name(), '', time()-42000, '/');
> }
>
> session_name();
>
> session_regenerate_id();
> session_destroy();
>
> // redirect browser back to login page
> header("Location: index.php");
> ?>
>
> imran shafiq wrote:
> >
> >
> > Dear Experts
> >
> > I am using session_start( ) and check $_SESSION['UName']for my every
> > php file to check user login and in my logout.php I define
> > session_start( );
> > session_destroy();
> > and check $_SESSION['UName'] is empty?
> > but when I call logout.php session not destroy and
> > $_SESSION['UName']not empty.
> > so, how to solve this problem?
> > <|_|_| | Hafiz
>
> > Imran Shafiq Khan
> >
> > [Non-text portions of this message have been removed]
> >
> >
>
> [Non-text portions of this message have been removed]
>
>
>
--
Grant S. Pollet, REALTOR
Austin TX
[Non-text portions of this message have been removed]