Logout Code

Jun 16, 2007

what code shall i write to logout from the site??? i have a website where i allow the users to access the webpages once they have login.

i want the users to logout on click of a logout hyperlink. if user tries to click on the back button of the browser after logging out it should display session expired.

i have written the code as
in all the pages after login

and on click of logout hyperlink the logout.php page opens where the code written is

if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
header("Location: index.php");

View 3 Replies


Logout Code Not Executing At All?

Here is the codeI dont know whats wrong with it.

//Logout code
//Starting Session


View 3 Replies

Login/Register/Logout Code

Basically, i want a link to login/register IF the person isnt logged in, but if they are logged in i want it to show a link to log out.

So basically, if you are logged out, login/register will show. If you are logged in, logout with show.

View 2 Replies

Html - How To Create A Logout Code

i'm using this code: but doesnt seem to work because the structure of my html file has 3 frames, a sidebar, title, and the main.

Now, the user will have two buttons, the call new sidebar. Which is only accessible if he has logged in. And the other button is log out. When the user press the call new sidebar. The sidebar will change into a user-only sidebar. Now, when the user clicks the logout button the sidebar which is only for users is still there. Is it possible to target two frames in html. Any other technique that you can recommend so that when the user logs off. There will be no other way to access the user-only sidebar.


View 3 Replies

Logout Feature In Code Igniter?

I started using codeigniter for my project. I have user authentication system for my website. I have seen the videos from nettuts for the login information. I am confused why the logout is not working properly. I have the following logout function in my login controller.

function logout() {

If I click on the logout button I am redirecting the user to the main page. But after redirecting the user to the main page, if click on the back button on the browser I will see the logoff and my name on the top of the page. I need some help on where I am going wrong or is there any important piece of code I am missing in my controller I think I found the solution. I should append the following code into the appropriate controller

$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");

View 1 Replies

Using A Logout Script (user Has To Click The Logout Link Twice)

I am having problems understanding the reason for why the user has to click logout twice, here's the bulk of the code:

require_once 'header.html';
require_once 'db.functions.php';
require_once 'config.php';


View 6 Replies

Logout Script Doesnt Logout

For some reason I am able to run my login script which after doing so will put more options into my menu to allow me to do other things. Well one option it brings up of course is "logout". Well for some reason it doesnt logout. I dont know if you will need more info but this is my log out script, I cant seem to see where the issue is. Code:

View 2 Replies

Need Help With Logout (logout Not Perfect)

I've written a login/logout code. It does what it's supposed to do but
the problem is when I logout and press browser's back button (in
Firefox), I get to the last login page. In IE, when I press back
button, I get to the page that says "Page has Expired" but Firefox does
not do this.

I think it's something to do with sessions not properly unset or
something like that but I haven't been able to figure it out. I am
attaching my codes and database structure below. If you need more info,
please email me. I really want this to be fixed asap. I've played with
this long enough.


class Login {
//var $loginflag;
//var $db_connect;

function Login() {
//$this ->db_connect = $db_connect;

if (!isset($_SESSION['uid']) || $_SESSION['uid'] == 0) {
echo "inside login class<br />";

function check_login($username, $password) {
global $db;

if ($_SESSION['logged']) {
echo "logged...<br />";
return true;
} else {
$username = mysql_escape_string($username);
$query = "SELECT * FROM users WHERE username = '$username' AND
AES_DECRYPT(password, 'dreamfilmslogin438ismbtsx') = '$password'";
$result = mysql_query($query, $link) or die("Could not select");

if (mysql_num_rows($result)) {
$this->set_session($username = mysql_fetch_assoc($result), true);
return $username['username'];
} else {
$this->failed = true;
return false;

function check_session() {
global $db;

$username = mysql_escape_string($_SESSION['username']);
$token = mysql_escape_string($_SESSION['token']);
$session = mysql_escape_string(session_id());
$ip = mysql_escape_string($_SERVER['REMOTE_ADDR']);

$query = "SELECT * FROM users WHERE username='{$username}' AND
token='{$token}' AND session='{$session}' AND ip='{$ip}'";
$result = mysql_query($query, $link) or die("Could not select");
echo "check session:<br />";
echo "<br />";
if ($result != false) {
} else {

View 25 Replies

Force Logout Of A Certain User Or Force Logout Of All Users?

I have a very basic php session login script. I want to force logout of a certain user or force logout of all usersHow can I read all sessions made to my website, and destroy some or all sessions?

View 3 Replies


How I can introduce in this line:

<span class="destqwhit">
<a href="alt_pass.php">Alterar Password</a> |
<a href="index.php?"> Logout</a>

the next PHP function for logout

if($_POST["logout"] != "")
echo "<meta http-equiv="refresh" content="0;URL=index.php">";

View 7 Replies

Session Cannot Logout

when i use the session, i will generate a key "SID" in URL to check the session.

for example, http://abc.com/test_session.php?SID...46d4a230468fa7a

After I had run the logout script, and then go back the previous page, the session will still here! how to solve it? pls help me!!!

for example,
----- logout script ------

View 3 Replies

Logout Button

how i can make a button refer to a php script. for example i've made a login section for my site and now i need to make the logout button but i have no idea how i can call the script to session_destroy().

View 5 Replies

Logout Fails To Log Out

Code: ( php )

View 3 Replies


I am creating a website that has a signup and a login/logout system...i cant continue with my work becoz im stuck with the login/logout system.

1. how do i build that login/logout system? (Just give me an idea or a particular php topic that wud be efficient for this login/logout scheme of mine)

2. how do i make this login/logout system prevent non-members from accessing the members page(Just give me an idea where to start and im happy)

View 3 Replies

Logout / Sessions

Is it possible to "see" when a user leaves your website? Because he leaves your site to visit an other site, or he closes his browser? Is this possible with an HTML code like "onClose"? And what if the user shut down his computer? Could I ping him with PHP to test if he's still on-line?

My second question is about sessions. What are the exact benevits above sending a own unique number with the user over the website? Like "a href = "test.php?id=32876483" ?

View 4 Replies

Session Logout?

Im trying to setup a user authentication by myself. So far... I create a session at the top. Register 3 session variables. (user, pass, status <-- logged in or not). And then check to see if user and pass are in the database. If they are... status gets switched to true.

The next thing... I would like to setup.. is logging out. I dont have much experience with Sessions... so I dont know how they work that much. But so far it seems like... if you declare a session variable... it will stay in the variable for a while :P

Well I was wondering if there was a way... to reset the session variables? So if someone clicks LOGOUT.... the 3 session variables are reset to noting.

View 4 Replies

Back After Logout

I have created a web in the 1st page. User can login. After login i start the session and save it in his db-record. Also the page give a link to my important page. In that page I check the saved sid and current sid. If both are equal, it will display some details, that page have the logout link.when user click that link. The logout.php will work. It generate a new sid for the
same user. my problem is after logout when the user back from logout.php it will show all contents of the my important page. If refreshing that page it didn`t show anything. So how can i make sure that when the user back it automatically refresh the page.

View 1 Replies

.htaccess Logout

how can I,as a Site User (Visitor) when i loged in with .htaccess logout myself again without closing my browser. Do you know any solutions in PHP,send a Header or something?

View 1 Replies

Logout And Login

I have created a code. The problem that I'm having is that the logout doesn't work. According to th book, the variable LOGOUT should be set to 1 when the link is clicked on, causing the relavent part of the if statement to unset the session variable.

This doesn't appear to be happening and the session is therefore never unsetting. what should i do to avoid?

View 3 Replies

Logout Isn't Logging Out

I am having an issue with this as once an individual is logged in it will not logout, even when clicking the Logout link. Here is my code for the logout: PHP Code:

$page_title = 'Logout'
include_once ('includes/header.html');

// If no first_name variable exists, redirect the user.
if (!isset($_SESSION['member'])) {

header ("Location: index.php");
ob_end_clean(); // Delete the buffer.
exit(); // Quit the script.

} else { // Logout the user.

$_SESSION = array(); // Destroy the variables.
session_destroy(); // Destroy the session itself.
setcookie (session_name(), '', time()-300, '/', '', 0); // Destroy the cookie.

View 1 Replies

Php Session Logout

I have a database of users. In this database, there is a field of whether the user is logged in (Y/N). When they login, the field updates to a Y. I still have not figured out to change the field to a N when they exit there browser.

i have a logout button that is an easy way to change the field as long as they click it. Is there a way to do this in case they just close the browser. Maybe a session timeout. I know banks do it all the time on there websites. I am just trying to alleviate multiple people trying to login into the same account and order product.

View 5 Replies

Logout In Catalog

session should expiry for a time period of 35 min when u logged into catalog in scommerce.

View 1 Replies

Logout Script

The code... ['logout.php']


if (isset($_COOKIE['Username'])) {


View 1 Replies

Logout Re-logs

I'm having a problem with my php script. My access control is embedded into each page that requires authentication. If the user id/pwd is not set and the POST vars userid and pwd are not set, then I display the login form. The login form action simply reloads the "self" page, which will now have userid and pwd POST vars set. My problem, is that if you log off, then click the back button, Firefox (and probably IE too) asks if you want to re-post form data.

$_POST = array();
$_SESSION = array();

View 1 Replies

Problem With Logout

I am using the following code which executes when ‘log out’ link is clicked: Code:

View 1 Replies

Logout Is Executed After 15 Min?

How logout is executed after 15 min. if does not hit or refresh any page.

View 3 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved