Are PHP session variables held in memory when you leave a PHP site?
I want to store some info in a PHP session variable, and have it be remembered as long as the session remains active, regardless of whether or not a user leaves my site for another site. Does leaving the domain cancel the session, or is this possible?
I am running PHP 4.2.3. |
Session variables are stroed on the clients computer in the form of cookies or can be transported via the URL. You can set these variables in your PHP script and restore them the next time the user requests your page. Here's the documentation on session function in PHP:
http://www.php.net/manual/en/ref.session.php |
I finally got the session variable to be read by the return page, what I had to do was call the "session_start()" function on both pages. I didn't catch that from the online manual.
|
Quote:
|
sessions are destroyed when the user closes the browser.
|
take it from me... I know... sessions are destroyed when they haven't been linked to for a certain amount of time. When the browser closes, the session-id cookie is destroyed, in turn this means the session that it links to has no more links. The gc (garbage collector), which is randomly initiated at certain intervals, then disposes of sessions that haven't been linked to in a set amount of time. It's all explained in the php manual (http://nl.php.net/manual/en/ref.session.php)
|
Yeah. Great. It's on the server side. The session is on the server side.
But is is in memory? or is it on disk? Is it inside a huge file with other things? or it's own file? Where is it? How can I "see" it and know it's there? Do I have to call functions to see it? Is that the only way? If it's on disk, I can find it and look at it. Delete it, et c. It's *similiar* to a client-side cookie. If it's in memory, then i need to run a function to return a value. I need to run a function to destroy it. If it's in memory does it die on it's own? how? when? what are the conditions? Do you see what I'm asking. I need to know that it is tangible so I can effectively manipulate it. How do I grab it and look at it? Don't point at manuals. I've already looked there, and it didn't help. What do YOU do? Or do you not even try to do these things. If you don't know, then just say "I don't know." or remain silent. If you do know. Then explain, please. |
A little reading would answer your plethora of questions. We're not here to hold your hand.
By the way, your piss take of a user name is not impressive or humorous in the slightest. |
As far as my understanding of session holds, the session gets destroyed the moment you close the browser. What you are looking for is really cookies. $_COOKIE['whatever'] = "data" should be what you need. If you are worried about security issues, you can possibly encrypt the cookie information. Other than that, no real reasons why you can't use cookies over sessions.
|
Okay, I didn't really read your second post. Now in response to your other post.
The first time you call session_start(), PHP basically generates a new session ID and creates an empty file to store session variables (therefore, the answer is, its in disk on server). PHP also sends a cookie back to the client that contains the session ID. But since the cookie is send in part of the HTTP headers in response to the broswer, you have to call the session_start function on the end of the server before you can access these session information using $_SESSION['whatever']. If you don't access session variables for a while, these information would be destroyed by PHP garbage collector. i dont know what you are trying to do here. But if you are trying to manipulate session so that you can prolong it and so that it does not destroy itself after you close the browser, you need to use session + cookies explicitly. That way, the cookies can store the session_id of the server on the client end. Making it possible for you to manipulate session stuffs. Other than that, i highly doubt that you can actually manipute the PHP stuffs on the server end unless you create an application on top of it [php]. Aaron http://aarontwc.blogspot.com |
Quote:
|
Here's an accurate answer:
|
All times are GMT -5. The time now is 10:48 PM. |