Miles, et al:

I realized my problem today, with the cookies.

While reading the voluminous setcookie() function description (meaning 
the user notes at the bottom), I came across a sample script that 
[EMAIL PROTECTED] had written to test to see if a browser is working with 
cookies correctly.  I ran the script and it too proved that cookies were 
not being received by my browser (for whatever reason).  So, in 
semi-frustration, I decided to do something else for a while and come 
back to the problem later.  I do that a lot.

So later I tried accessing the script that [EMAIL PROTECTED] had written 
again, this time from a different computer.  Because I was trying the 
page out on a non-local computer (previously I had been testing the page 
on the localhost -- the webserver itself), I had to enter the official 
IP address of the web server, rather than the default for 
local hosts.

Sure enough, the script gave me the signal that cookies were working 
again.  I couldn't believe it.  Why was it working on this other 
computer but not mine?

Yep, for whatever reason it's because I used the official IP address 
this time.  I went back to the localhost (the web server computer) and 
tried the pages again, both my original script and the one I got from 
the setcookie() comments.  This time, I was properly prompted as to 
whether or not I wanted to accept a cookie.

So it works!  You just have to use the correct IP address.

Okay, thanks Miles and hope this information serves someone else in the 
future.  Now I can go home (almost 8 PM!!).

-- Erik

On Wednesday, December 26, 2001, at 04:40  PM, Miles Thompson wrote:

> Erik,
> 1. Did you just try setting a cookie, plain, with no conditions.
> 2. Have you tested your conditions, or added a test, equivalent to what 
> you
> do when you set the cookie? In other words, change setcookie to 
> this ....
> if ($type_sel)
> {
>    setcookie("font[type]", $type_sel, time()+3600) ;
>    echo "type_sel: $type_sel;
> }
> 3. Are you getting any errors when you try to set the cookie?
> Miles
> On Wednesday 26 December 2001 05:07 pm, Erik Price wrote:
>> I used
>> <code>
>> <?php
>> // cookie_test.php
>> if ($type_sel) setcookie("font[type]", $type_sel, time()+3600) ;
>> if ($size_sel) setcookie("font[size]", $size_sel, time()+3600) ;
>> </code>
>> (without the <code /> tags)
>> This is a page which calls itself ($PHP_SELF) (is there a name for
>> those?).  And these variables are set by choosing from a select-list at
>> a different part of this page.  It's very basic, no if or case
>> statements -- just basically a page that delivers a pair of values
>> (font[type] and font[size]) to setcookie() and then checks to see if
>> there is a cookie in the browser that matches this description.  If
>> there is, it outputs some simple data, and at the very bottom it echoes
>> the contents of all variables so I can check and make sure everything's
>> working.  That's how I know that the setcookie() function doesn't seem
>> to work -- there's no value in the cookie variables but if I echo the
>> variables that I used ($type_sel and $size_sel) then it outputs the 
>> data.
>> I'll read about IE, it's 5.1 for Mac OS X.
>> Erik
>> On Wednesday, December 26, 2001, at 03:12  PM, Miles Thompson wrote:
>>> Erik
>>> What code are you using to set your cookie?
>>> Are you certain the expiry date is in the future?
>>> What browser are you using? There are notes in the online manual
>>> ( regarding IE.
>>> Miles
>>> On Wednesday 26 December 2001 04:01 pm, Erik Price wrote:
>>>> Hello,
>>>> I am having a problem testing out the use of cookies.  I'm using a
>>>> tutorial from Wrox's "Beginning PHP4".  It seems that I'm doing
>>>> everything correctly, but when I try to access the page in my
>>>> browser, I
>>>> am not prompted as to whether or not I'd like to accept a cookie 
>>>> (which
>>>> is something that I have configured my browser for), nor do the 
>>>> values
>>>> that I assigned to the cookies show up in the test variables that I
>>>> included on the page for just this purpose.  In other words, I'm not
>>>> sure that the setcookie() functions are working -- the variables 
>>>> that I
>>>> set using "setcookie()" don't seem to be turning up on the page, but
>>>> the
>>>> standard form-based variables that I used (as values in the 
>>>> setcookie()
>>>> function) turn up just fine.
>>>> Do I need to have my web server specially configured for using 
>>>> cookies?
>>>> I don't see anything in httpd.conf about this.
>>>> My setup is as follows:
>>>> Darwin 1.4.1 on PowerBook G3 (Bronze edition, no firewire)
>>>> Apache 1.3.22
>>>>    configured with --enable-module=most --enable-shared=max
>>>>    DSOs: mod_dav, mod_hfs_apple, mod_php
>>>>            (PHP 4.0.6)

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to