Connecting Tech Pros Worldwide Forums | Help | Site Map

where does php place cookies?

Marcus
Guest
 
Posts: n/a
#1: Oct 4 '05
Hello all,

This is baffling me. I am starting a session and I know it is setting a
cookie on my computer - I called getallheaders() and see that it is
setting the cookie, and it is also accessible in $_COOKIE. I cleared
all cookies in my Cookies folder before starting the session, and
everytime I run the script it does not create a cookie in the folder.
For testing I even set the browser to accept all cookies to make sure.

session.use_cookies is on in php.ini, session.use_only_cookies is off,
and session.use_trans_sid is off. The session data file is definitely
being created, but I cannot find the corresponding cookie no matter what
I try.

Thanks in advance for all your help.

Wayne
Guest
 
Posts: n/a
#2: Oct 4 '05

re: where does php place cookies?


On Tue, 04 Oct 2005 04:11:07 GMT, Marcus <JumpMan222@aol.com> wrote:
[color=blue]
>This is baffling me. I am starting a session and I know it is setting a
>cookie on my computer - I called getallheaders() and see that it is
>setting the cookie, and it is also accessible in $_COOKIE.[/color]

PHP sessions use so-called "session cookies" -- they are not
perminently stored and disappear when you close your browser. Thus
they are never written to you cookies folder.

Marcus
Guest
 
Posts: n/a
#3: Oct 4 '05

re: where does php place cookies?


Wayne wrote:[color=blue]
> On Tue, 04 Oct 2005 04:11:07 GMT, Marcus <JumpMan222@aol.com> wrote:
>
>[color=green]
>>This is baffling me. I am starting a session and I know it is setting a
>>cookie on my computer - I called getallheaders() and see that it is
>>setting the cookie, and it is also accessible in $_COOKIE.[/color]
>
>
> PHP sessions use so-called "session cookies" -- they are not
> perminently stored and disappear when you close your browser. Thus
> they are never written to you cookies folder.
>[/color]

That explains a lot. :-) Thanks Wayne.

Are they put in any other directory, or do they just reside in the
server's RAM or some other temporary storage device?
Yandos
Guest
 
Posts: n/a
#4: Oct 4 '05

re: where does php place cookies?


Marcus wrote:[color=blue]
> Wayne wrote:[/color]
[snip][color=blue]
>
> That explains a lot. :-) Thanks Wayne.
>
> Are they put in any other directory, or do they just reside in the
> server's RAM or some other temporary storage device?[/color]

They reside in *your computer's RAM* allocated by the browser, not on
the server side. They are never written to disk (until you are short of
free RAM - then you can maybe find them in your swapfile/swap partition :))

Y.
Wayne
Guest
 
Posts: n/a
#5: Oct 4 '05

re: where does php place cookies?


On Tue, 04 Oct 2005 06:13:34 GMT, Marcus <JumpMan222@aol.com> wrote:
[color=blue]
>Are they put in any other directory, or do they just reside in the
>server's RAM or some other temporary storage device?[/color]

I assume you mean client's RAM not server's RAM -- and yes, that is
where they reside.

Marcus
Guest
 
Posts: n/a
#6: Oct 4 '05

re: where does php place cookies?


Wayne wrote:[color=blue]
> On Tue, 04 Oct 2005 06:13:34 GMT, Marcus <JumpMan222@aol.com> wrote:
>
>[color=green]
>>Are they put in any other directory, or do they just reside in the
>>server's RAM or some other temporary storage device?[/color]
>
>
> I assume you mean client's RAM not server's RAM -- and yes, that is
> where they reside.
>[/color]

Yes, I'm sorry, I spent 10 hours straight coding and researching stuff,
and my brain was fried at 1 am. :-)

If it does reside in RAM, how can you set it to have a lifetime of
years? Once the user turns the computer off, doesn't this flush the
system memory and thus kill any cookie settings that were set?
Gordon Burditt
Guest
 
Posts: n/a
#7: Oct 4 '05

re: where does php place cookies?


>If it does reside in RAM, how can you set it to have a lifetime of[color=blue]
>years? Once the user turns the computer off, doesn't this flush the
>system memory and thus kill any cookie settings that were set?[/color]

Look at the PHP documentation for setcookie(). A session-only
cookie (one created by calling setcookie with an expire time of 0)
will expire when the browser is closed. It doesn't have an expire
time, and might manage to last more than 2 years if the browser
stays open that long. It's not stored on disk, at least in most
browsers.

A non-session-only cookie will have an expire time, often given to
setcookie() as time() + a number of seconds to last. These cookies
will be stored on disk somewhere. Where depends on the browser,
but it's likely to be in a similar place to where the browser
configuration parameters are stored.

Gordon L. Burditt
Closed Thread