destroy 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
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

destroy sessions

Post by potato »

is there a function that i can use to destroy all the sessions on the server?
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

Delete all the files in the sessions folder.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

session_destroy(); to delete them
session_unset(); to unset them
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

Phenom wrote:session_destroy(); to delete them
session_unset(); to unset them
But that concerns only one session, not all on the server. I think.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

MarK (CZ) wrote:
Phenom wrote:session_destroy(); to delete them
session_unset(); to unset them
But that concerns only one session, not all on the server. I think.
I think you couldnt be more wrong.

a better way of clearing sessions is:

Code: Select all

<?php
$_SESSION = array();
session_destroy();
?>
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

So if you use 'session_destroy()' it will erase ALL session data from ALL users connected to the server??
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php

$_SESSION = array(); 
session_destroy(); 

?>
whats the difference from
session_destroy();
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why not set garbage collection to 100% in the ini?
Post Reply