For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > February 2005 > Cookie Problems on Localhost









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Cookie Problems on Localhost
Joseph L. Mueller

2005-02-23, 8:56 am

I am testing some PHP code (example 15.5 from Sams Teach Yourself PHP
MySQL, PHP and apache in 24 Hours). I am running running PHP 5.0.3 and
Apache 2.0.43 on my WinXp Home system.

My problem is I cannot seem to set a cookie.
<?php
setcookie("vegetable", "artichoke", time()+3600, "/", "127.0.0.1", 0);
?>

I tried using "localhost" and "127.0.0.1" for the domain parameter, but
that does not seem to work. I have tried this with botn Mozilla 1.7.3
and Internet Explorer to no avail.

Any pointers would be welcome.

Thnaks in advance.
--
Joseph L. Mueller
M. Sokolewicz

2005-02-23, 3:56 pm

Joseph L. Mueller wrote:

> I am testing some PHP code (example 15.5 from Sams Teach Yourself PHP
> MySQL, PHP and apache in 24 Hours). I am running running PHP 5.0.3 and
> apache 2.0.43 on my WinXp Home system.
>
> My problem is I cannot seem to set a cookie.
> <?php
> setcookie("vegetable", "artichoke", time()+3600, "/", "127.0.0.1", 0);
> ?>
>
> I tried using "localhost" and "127.0.0.1" for the domain parameter, but
> that does not seem to work. I have tried this with botn Mozilla 1.7.3
> and Internet Explorer to no avail.

both 'localhost' and any ip are not accepted as valid domain-identifiers
in cookies (as per RFC). This simply means you're best off leaving them
empty.
>
> Any pointers would be welcome.
>
> Thnaks in advance.

Joseph L. Mueller

2005-02-23, 3:56 pm

M. Sokolewicz wrote:

> Joseph L. Mueller wrote:
>
>
> both 'localhost' and any ip are not accepted as valid
> domain-identifiers in cookies (as per RFC). This simply means you're
> best off leaving them empty.
>
>

That still leaves the problem of how to test cookies and sessions on a
local system.

--
Joseph L. Mueller
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com