logout script not working !

i made a website which had log in capabilities and when not logged in the user was directed to index2.html
and when logged in user entered index.html. here there was a logout link \logout.php which always gave successful logout. but when it redirected to \index.html no logout had took place ?? index2.html had a form of username and password which were validated by login.php.
i pls. need help

http://chat.megh.tk/
username : anonymous
password : password

index.html
[php]<?php

session_start();

if (!(isset($_SESSION[‘userName’]))||($_SESSION[‘userName’]=="")) echo ("");
else
echo $_SESSION[‘userName’];
?>

       <title>mChat</title>
      </head>
      <body>

Logout


The easiest way in PHP code is to call out to another page that does the redirect.
So, you would have the Index.html page which would be the default page that everyone goes to.

This page would contain your login options, usually just a username and password and a “LogIn” button.
This of course would be inside a form. Pressing the log-in button would submit the form to a processing page to validate the ID and Password. If okay, it sends them to index2.

The “logged-in” user would NEVER go back to the index page. And, you would never log-out from an index page. The first line of the index page would be to set the session for the user to null.
(This forces logout and login!)

Once a user is logged in and validated as okay, set the session variable with their userID.
At the top of every page check for this. If null (as in the index.html page), it will pass to a
“You are not allowed here” page. To use a logout button, just set the session variable to null
and redirect to the index page.

This is how I redirect in PHP:
[php]
if(!$_SESSION[‘UserID’]) {
session_unset(); //Remove the session…
header(“Location: IllegalAccess.html”); //Go to the not-allowed-here-page…
}
[/php]
Not sure if that is what you need, but, hope it helps…

i solved it
i integrated login.php into index.htlm through post with a hidden input box

Sponsor our Newsletter | Privacy Policy | Terms of Service