Current location: Hot Scripts Forums » Programming Languages » PHP » Problem with logout button


Problem with logout button

Reply
  #1 (permalink)  
Old 04-08-08, 10:31 PM
agarwalsrushti agarwalsrushti is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Problem with logout button

I have made a website wherein the user creates his account. If the user logsout he is directed to the home page. But the problem is if the user clicks on the back button then he is again directed to his account. The session again starts for the user which should not be the case. I ve used header caching at top of every page but still same problem continues.
What could be the possible solution.
Reply With Quote
  #2 (permalink)  
Old 04-08-08, 10:41 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Could you show us the logout code? would help alot
__________________
01010000 01001000 01010000
Reply With Quote
  #3 (permalink)  
Old 04-08-08, 10:46 PM
agarwalsrushti agarwalsrushti is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<p><a href="index.html" class="style14">Logout</a></p>

session_unset();
session_destroy(); 
I know there is some mistake even in the code.
I ve given the logout as a link. Can you help as how can i solve this problem.
Reply With Quote
  #4 (permalink)  
Old 04-08-08, 10:55 PM
agarwalsrushti agarwalsrushti is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<?php

    header
("Expires: Thu, 17 May 2001 10:17:17 GMT");    // Date in the past
    
header ("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT"); // always modified
    
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
    
header ("Pragma: no-cache");                          // HTTP/1.0
    
    
session_start();
    
// Unset session data
    //$_SESSION=array();
    // or...
    
session_unset();
    
// Clear the session cookie
    
unset($_COOKIE[session_name()]);
    
// Destroy session data
    
session_destroy();
    
    
header("Location: ../login_system.php");
    exit;
?>
This would be the code for logout and it is stored in a file called logout.php
Should i just redirect the user to this file when he clicks the logout link.
Reply With Quote
  #5 (permalink)  
Old 04-08-08, 11:45 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
mmm yes, you need to link the logout button to a different file.
im not sure why your code is not working.

This is how i do it:
PHP Code:

        $_SESSION = array() ;


        if (isset(
$_COOKIE[session_name()]))
        {
            
setcookie(session_name(), ''time()-42000'/') ;
        }

        
session_destroy() ; 
to redirect i just use this:
PHP Code:

echo "<meta http-equiv='refresh' content='$time;URL=$url'>" ;

exit ; 
I obviously put this in to a function for easy use

Hope that helps,
Lex
__________________
01010000 01001000 01010000
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to disable browser's back button after logout shaky ASP 7 08-18-06 07:37 AM
SQL/Coldfusion radio button problem..... Clark_Kent Other Languages 1 07-19-06 04:43 PM
ASP dynamic button problem kasic ASP 2 05-10-04 09:17 AM
Back button problem selvam PHP 3 05-07-04 09:41 AM
Problem with SWITCH function in Radio Button group maverickblair PHP 1 02-27-04 10:49 AM


All times are GMT -5. The time now is 07:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.