Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Destroying Sessions? |
|
Author |
|
kr33
Joined: 19 Sep 2006 Posts: 64 Location: South Africa
|
Posted: Thu 02 Nov '06 12:41 Post subject: Destroying Sessions? |
|
|
Another question I have is...
How do I clear the session completely, without having to close the browser in order to do that, because if i bypass the login page after already having logged in before, i can still view the pages(assuming the browser hasn't been closed and reopened)
I've tried the following:
Code: |
<?php
session_name("name");
session_start();
session_destroy();
?>
|
i have the following in the login page
Code: |
<?php
session_unset();
?>
|
shouldn't that be enough, so that I don't have to close the browser every time, so that the session closes?
Please help, thanks |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Thu 02 Nov '06 13:21 Post subject: |
|
|
Code: |
session_name("name");
session_start();
//Cookie Client deleting
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
//Cookie on serverseitig deleting
session_destroy();
$_COOKIE=null;
$_SESSION=null;
|
If this is on the logout page You don't have to close the browser.
use session_destroy to end a session. session_unset only empties the variables but does not finish the session |
|
Back to top |
|
kr33
Joined: 19 Sep 2006 Posts: 64 Location: South Africa
|
Posted: Thu 02 Nov '06 13:43 Post subject: |
|
|
I'm not using cookies at all, i only using sessions.
I tried what you've said in the previous post, and i get some error about function:destroy() or something like that.
And it hasn't solved the problem.
Any other alternatives, but ONLY using sessions, I have no cookies,
what-so-ever.
Anything?
Thanks |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Thu 02 Nov '06 15:20 Post subject: |
|
|
The session will create a session cookie But browsers don't handle that as a normal cookie. |
|
Back to top |
|
kr33
Joined: 19 Sep 2006 Posts: 64 Location: South Africa
|
Posted: Thu 02 Nov '06 15:39 Post subject: |
|
|
OK...Thanks alot!
I'll post another message and let you know what the outcome is and if it worked!
Oh by the way, do I type the following on every page?
Code: |
<?php
session_name("name");
session_start();
?>
|
or just
Quote: |
Code: |
session_name("name");
session_start();
//Cookie Client deleting
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
//Cookie on serverseitig deleting
session_destroy();
$_COOKIE=null;
$_SESSION=null;
|
|
in login page and then in the main frameset
Code: |
<?php
session_name("name");
session_start();
?>
|
thanks again |
|
Back to top |
|
kr33
Joined: 19 Sep 2006 Posts: 64 Location: South Africa
|
Posted: Thu 02 Nov '06 15:47 Post subject: |
|
|
Hi
I tried the code you gave me, to put into the beginning of my login in page and it works perfectly, thanks alot
Now I fully understand how to work with this session story, but I will work on perfecting my web development skills, I migrated from Windows applications to web development so bare with me.
I also realised that there is no need for the session_unset() method as the above code deletes the last opened session. Right?
Thanks again |
|
Back to top |
|
|
|
|
|
|