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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sessions and cookies 1

Status
Not open for further replies.

solex

Programmer
Joined
Feb 28, 2003
Messages
91
Location
GB
Hi all,

I have been useing sessions for ages now, and dabbled at the start with linking them to cookies, but it did not work :s , i now need to link the two. I have tried to use the php manual, but not found it much help.

So does any one have a snippet of code i can nick to store a session in a cookie?

thank you in advance
solex
 
The whole point of sessions is that they aren't stored in cookies. Cookies can be meddled with by users and have limited storage capacity.

That's why PHP's session-handling mechanism stores the session variables on the server and sets a single session cookie on the client. The server can use the session cookie as an index to the session data store, but the session data is kept safely away from prying users.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thats is what i ment i wanted to happen, i want the session to remain on the computer, even after the user has left the site/closed the browser. How do i do this?

thanx
solex
 
Before you invoke session_start(), use ini_set() to set the runtime configuration value session.cookie_lifetime to the number of seconds you want the cookie to live (from the time the cookie is set).

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thank you

solex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top