Php With Sessions Aah

First of all i am new to PHP Session.
THE PROBLEM:
I do session_start(); command at the begening of every page so that php uses session but what i also what it to do is that if that person closes the browser and returns back to same website it should atleast pick up the person's user name so that they dont have to type it again and again when ever they come back. plus to that every single time that person close the browser and come back to that website it creates a new session which is painful as each session take space on the webserver. any idea on how to get the php to get the session id of an old session that was made by the same website and run that session if it is available. any tips on session is good as i was not able to find good documentation on php.net regarind this problem.

I think you should use cookies. I also think you should look at this script. The top of this page has a great php login with session handling and cookies for automatic re-login. I have the link here though to my comment on the script that will have some extra stuff

The original code is good but requires a PEAR connection to a mysql db. I don’t use PEAR so I re-wrote the script with some small changes. that’s why I want you to go to my comment because you can download the whole class instead of putting their puzzle peaces together

PHP transparently supports HTTP cookies. Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users. You can set cookies using the setcookie() or setrawcookie() function. Cookies are part of the HTTP header, so setcookie() must be called before any output is sent to the browser. This is the same limitation that header() has. You can use the output buffering functions to delay the script output until you have decided whether or not to set any cookies or send any headers.

Any cookies sent to you from the client will automatically be turned into a PHP variable just like GET and POST method data, depending on the register_globals and variables_order configuration variables. If you wish to assign multiple values to a single cookie, just add [] to the cookie name.

In PHP 4.1.0 and later, the $_COOKIE auto-global array will always be set with any cookies sent from the client. $HTTP_COOKIE_VARS is also set in earlier versions of PHP when the track_vars configuration variable is set. (This setting is always on since PHP 4.0.3.)

For more details, including notes on browser bugs, see the setcookie() and setrawcookie() function.