Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Understanding Cookies

0 views
Skip to first unread message

Mike

unread,
Nov 7, 2005, 8:17:09 PM11/7/05
to
Hello,
I have been trying to get cookies to work. It seems I can get this cookie to
be persistant in the browser but I want to write it to my Cookies Folder.
I have tried many variations but when I look in the folder there is nothing
there from my Domain.
This is a simlified version but, I have tried many things.
What am I missing?
Yes I allow all cookies
Thanks
Mike


Andy Hassall

unread,
Nov 7, 2005, 8:43:10 PM11/7/05
to
On Tue, 08 Nov 2005 01:17:09 GMT, "Mike" <ampe...@verizon.net> wrote:

>I have been trying to get cookies to work. It seems I can get this cookie to
>be persistant in the browser but I want to write it to my Cookies Folder.
>I have tried many variations but when I look in the folder there is nothing
>there from my Domain.
>This is a simlified version but, I have tried many things.

What have you tried?

Presumably you have read and followed the examples at
http://uk.php.net/setcookie ?
--
Andy Hassall :: an...@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Mike

unread,
Nov 7, 2005, 8:51:47 PM11/7/05
to
Yes,
Heres a perfect example;
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
?>
Can be found at:(My Domain)
http://www.ampsoft.com/B.php

I leave the browser open and check my Cookies folder and ...Nothing .
Thanks
Mike

"Andy Hassall" <an...@andyh.co.uk> wrote in message
news:4k00n19af9ci53k1a...@4ax.com...

Andy Hassall

unread,
Nov 7, 2005, 8:57:16 PM11/7/05
to
On Tue, 08 Nov 2005 01:51:47 GMT, "Mike" <ampe...@verizon.net> wrote:

>Heres a perfect example;
><?php
>$value = 'something from somewhere';
>setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
>?>
>Can be found at:(My Domain)
>http://www.ampsoft.com/B.php
>
>I leave the browser open and check my Cookies folder and ...Nothing .

That works for me, both on Firefox 1.5RC1 and Internet Explorer 6.

A cookie is set and stored; contents of the file from IE is:

TestCookie
something+from+somewhere
www.ampsoft.com/
1024
3124430464
29746191
1793278832
29746183
*

Add the following:

print "<pre>";
var_dump($_COOKIE);
print "</pre>";

Then you will be able to see what cookies the browser has accepted and sent
back.

If you're not getting anything, then you have a browser configuration problem.

Mike

unread,
Nov 7, 2005, 9:24:37 PM11/7/05
to
I'm getting:array(0) {

}
"Andy Hassall" <an...@andyh.co.uk> wrote in message
news:4d10n1lmmd3agkvv8...@4ax.com...

Geoff Berrow

unread,
Nov 8, 2005, 1:52:18 AM11/8/05
to
Message-ID: <F%Tbf.4061$SV1.3415@trndny01> from Mike contained the
following:

>I'm getting:array(0) {
>}

Try refreshing it.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

ampe...@gmail.com

unread,
Nov 8, 2005, 12:20:53 PM11/8/05
to
It seems to me that the cookie wont store on the client if there is no
expiration time,which contradicts the Documentation which says if there
is no exp. time it lasts until the browser closes.

Kim André Akerø

unread,
Nov 8, 2005, 1:00:23 PM11/8/05
to
ampe...@gmail.com wrote:

They /are/ stored on the client computer. You just need to read *all*
of the manual page:

<quote>
Once the cookies have been set, they can be accessed on the next page
load with the $_COOKIE or $HTTP_COOKIE_VARS arrays.
</quote>

(Just below the table where the parameters are explained in detail.)

--
Kim André Akerø
- kima...@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

ampe...@gmail.com

unread,
Nov 8, 2005, 1:55:38 PM11/8/05
to
Yes, But they are not written to the Cookies folder unless there is an
expiration time.I tried this several times.
Run http://www.ampsoft.com/Doesnt.php
Refresh as much as you want---No cookie written to disk(Cookies Folder)
Run http://www.ampsoft.com/Does.php
Refresh - a cookie is written.

Doesnt:
<?php
$value = 'This cookie doesnt write';
setcookie("TestCookie", $value);
?>

Does:
<?php
$value = 'This cookie writes';
setcookie("TestCookie", $value,time()+3600); /* expire in 1 hour */
?>

Kim André Akerø

unread,
Nov 8, 2005, 2:02:50 PM11/8/05
to
ampe...@gmail.com wrote:

> Yes, But they are not written to the Cookies folder unless there is an
> expiration time.I tried this several times.
> Run http://www.ampsoft.com/Doesnt.php
> Refresh as much as you want---No cookie written to disk(Cookies
> Folder) Run http://www.ampsoft.com/Does.php
> Refresh - a cookie is written.
>
> Doesnt:
> <?php
> $value = 'This cookie doesnt write';
> setcookie("TestCookie", $value);
> ?>

It did, and I'm using Opera 8.5. Although it doesn't have a cookies
"folder", it does allow me to access all cookies set for all domains.

For the "expire" parameter of setcookie():
"If not set, the cookie will expire at the end of the session (when the
browser closes)."

> Does:
> <?php
> $value = 'This cookie writes';
> setcookie("TestCookie", $value,time()+3600); /* expire in 1 hour */
> ?>

--

Andy Hassall

unread,
Nov 8, 2005, 2:06:58 PM11/8/05
to
On 8 Nov 2005 10:55:38 -0800, ampe...@gmail.com wrote:

>Yes, But they are not written to the Cookies folder unless there is an
>expiration time.

If there is no expiration time, then the cookie is valid until the browser
window is closed.

So, why should the browser bother writing it to disk when it can just keep it
in the area of memory associated with that browser window?

ampe...@gmail.com

unread,
Nov 8, 2005, 2:10:12 PM11/8/05
to
I'm using IE and there is definitly a difference
Anybody out there with IE, let me know, Please
ampe...@verizon.net
Thanks
Mike

windandwaves

unread,
Nov 8, 2005, 3:48:16 PM11/8/05
to

I dont doubt that it is not working for you, but to say that it does not
work would be out of the question, because 1000s of people around the world
are using this method very successfully. There must be something else that
is wrong, e.g.

- php not installed correctly
- caching problem
- etc...

0 new messages