473,513 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Logout Session - not working

144 New Member
hi,

i'm learning and trying to develop a web with php. the logout script of mine seems not working since that after i pressed the logout link. i still get the greeting "welcome, 'username' ".

this is the script in the logout.php that

[PHP]
<html>
<head>
<meta http-equiv="refresh" content="1; URL=index.php">
</head>

<body>
<?
//destroy session and redirect user
session_start();

session_unset();
session_destroy();

//redirect using meta tag
?>
</body>
</html>
[/PHP]

hope someone could help. thx
Dec 24 '07 #1
7 3428
nothing1
30 New Member
this is a quote from http://us3.php.net/session_unset
You should go there and read more. Also it depends on what php version your using.

sometimes you might have problems even if using both session_unset and session_destroy. You have to clear the $_SESSION array. I got it working this way:

[PHP]session_unset();
session_destroy();
$_SESSION = array();[/PHP]
Dec 24 '07 #2
thesti
144 New Member
hi,
thx nothing

well, it works if i use html form as the logout method. the problem just that i don't want to display the logout as a submit button. i want it to be displayed as a link

is there any work around..

thx
Dec 24 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, Thesti.

What happens if you refresh index.php after logging out? You might just be seeing a cached version of index.php.
Dec 24 '07 #4
thesti
144 New Member
hello,

after some changes, it works well with FF and IE. but it doesn't work with Opera. even after i refresh the page. can i solve this problem?

thx
Dec 25 '07 #5
pbmods
5,821 Recognized Expert Expert
Heya, Thesti.

Try redirecting to index.php?loggedout=true. The loggedout=true part wouldn't affect your logic, but it would prevent the browser from serving the cached version of the page because "index.php" != "index.php?loggedout=true".
Dec 25 '07 #6
thesti
144 New Member
i've tried your suggestion to use GET method, but still it doesn't work with Opera. i also have tried to use the no-cache and last-modified things but that doesn't solve the problem too

wonder if this only happen to me. still working to solve this...
Dec 25 '07 #7
grimjoey
1 New Member
JS workaround for the submit button to show as link:
Expand|Select|Wrap|Line Numbers
  1. <form action="" method="post">
  2. <input type="hidden" name="logout" value="true" />
  3. <a href="#" onclick="document.getElementById('submitbutton').click();">Logout</a>
  4. <input id="submitbutton" type="submit" name="submit" value="test" style="display: none;">
  5. </form>
Dec 25 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2235
by: Phil Powell | last post by:
class LoginSessionGenerator extends MethodGenerator { function LoginSessionGenerator() {} /** * Logout * * @access public */ function &logout() { // STATIC VOID METHOD
6
14641
by: Jeff | last post by:
I've searched the web for hours trying to figure out this problem and can't seem to find any pertinent answers. I have a website where the user starts on a login page, puts in their credentials and...
4
11230
by: ad | last post by:
I use the Login controls of Asp.net 2.0 in my program. I want to logout a user by program, I try Session.Abandon() for this. But I found that the user is the same after I execute Session.Abandon()....
25
3294
by: crescent_au | last post by:
Hi all, 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,...
7
9338
by: pank | last post by:
hey guys ... can anybody tell me a php logout script. I want to log out from one page which i was developing , i tried but it's not working. I have tried session_destroy(),session_unset()...
3
6322
by: roshni86 | last post by:
I have the following code for a logout of an account in php.However it is not working,as when i press the "back" button,the page returns to the previous page where a user had signed and viewed. ...
1
14031
by: shrik | last post by:
hi everybody. I have following problem. There are two pages. index.jsp and main.jsp in my application Index.jsp contains logging interface in . It submits password and userid to loginform bean. ...
1
3313
by: Kandiman | last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?... heres the code.. i think its on the value=true...
6
5963
by: Thiago Macedo | last post by:
I could not find on the web a complete solution for this task. This is not the perfect solution, because it's doesn't have the ability to log the logout if browser crash or user leave it open while...
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7545
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.