Garbage Collection in PHP session
Moderator: General Moderators
Garbage Collection in PHP session
I'm tried to introduce Garbage Collection for my session files but php creates other session files that are not the ones I use; therefore garbage collection does not work. What php script can I write to achieve garbage collection through scripts ?
Last edited by saibot1 on Sat Dec 16, 2006 2:27 pm, edited 1 time in total.
Please explain in more detail why you're trying to write what seems to be your own session data storage and why you do it this way.
Of course the session gc does not work with just arbitrary code. If you need your own session handler but want to use some parts of php session management have a read of http://de2.php.net/session_set_save_handler
Of course the session gc does not work with just arbitrary code. If you need your own session handler but want to use some parts of php session management have a read of http://de2.php.net/session_set_save_handler
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
If this session information is anywhere near critical, I would suggest against using IP's as they can change or even be mocked.saibot1 wrote:By creating sessions that way I can know what was the ip address of the person that made that file and associate it with the person that made it if any problems occur.
One or the other would be the best way to go, in my opinion. Either use PHP's sessions, or develop your own session handling from the ground up. It is not that hard to do, but you should consider your needs and why you want to do things the way you are doing them.saibot1 wrote:By using php.ini I was trying to use an easy way to do garbage collection but I think using regular scripts may be actually easier.
As another suggestion, can't you just use PHP's session handling to fetch your users IP and session that data in the session array?