Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sess files piling up

Status
Not open for further replies.

DaveC426913

Programmer
Jul 28, 2003
274
CA
I'm changing my app from form posts to session variables, which I'm just learning about. All I want to do is have access to a few variables across several pages.

This is the technique I'm using:

<?php session_start(); ?>
...
$foo = $_SESSION['foo'];
...
$_SESSION['foo'] = $foo;


But now I find my directory filling up with sess files. Am I going to get a sess file for *every* user that goes to my site?? They'll quickly overtake my folder with junk. Are there any good techniques for managing these files? Seclude them in a subfolder? Delete them?
 
Am I going to get a sess file for *every* user that goes to my site??
Yes. That's how PHP, by default, stores session data.

They'll quickly overtake my folder with junk.
Not necessarily. There are php.ini configuration options that can tailor how many are kept around, where they are stored, and how often they are deleted by PHP's garbage collection.

Are there any good techniques for managing these files? Seclude them in a subfolder? Delete them?
For runtime configuration options and what they do, see: and
faq434-4908

For storing PHP session data in a MySQL database instead of on the filesystem, see: faq434-2037


Want the best answers? Ask the best questions! TANSTAAFL!
 
Note the session.gc_* settings in your php.ini file... the gc stands for garbage collection.

Basically everytime you start a new session there's a random chance that PHP will cleanup any old and dead sessions.

Also take note that if you're stuck on a FAT Filesystem things aren't going to work so well for you.


Sidebar: You say cluttering your folder... you can also change the save path so they go to some folder which has nothing but session files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top