Problems closing sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Perfidus
Forum Contributor
Posts: 114
Joined: Sun Nov 02, 2003 9:54 pm

Problems closing sessions

Post by Perfidus »

Is it possible to close a session wihout closing browser?
Should this close a session?
I have this to close a session in my web, but after this, when you are taken to acceso6.html it still recognise the session.
:(
<?php
session_start();
session_unset();
session_destroy();
header("Location: /acceso6.html");
?>
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

Try this.

Code: Select all

<?php
session_start(); 
$_SESSION = array(); 
session_destroy(); 
header("Location: /acceso6.html"); 
?>
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

i had the same problem as this guy, cant remember how i fixed it tho :oops:
User avatar
Luis Almeida
Forum Commoner
Posts: 33
Joined: Tue Apr 01, 2003 4:22 am

Post by Luis Almeida »

I used to have the same problem but i saw the following code somewhere and it works fine

Code: Select all

<?php
session_unset(); 
session_destroy(); 
$p = session_get_cookie_params(); 
setcookie( session_name(),  "",   0, $p ["path"], $p["domain"]); 
?>
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

actually the code that perfidus had, i fuond on a tutorial and copied and pasted it, it didnt work :( , dont you hate it when tutorials tell you the wrong things! or maybe its works for an older version of PHP, not sure
Post Reply