By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

TCL, PHP and cookies - AUGH!

P: n/a
Ok now it has turned to the bizarre.

In /cma/index.php, which sets the cookie:

setcookie('username', $username, time() + 600);
....
header("Location...");

It redirects to the TCL CGI /cma_main.cgi which in turns does NOT see the
cookie name "username" ever set. I go to my /Phil/Cookies folder for the
cookie under the "valsignalandet.com" domain and, sure enough, "username" is
not set. However, $HTTP_COOKIE_VARS["username"] DOES exist every time I go
to /cma/index.php thereafter, in spite of nothing else showing a cookie
exists.

So, in short, "setcookie()" in PHP is setting a nonexistent cookie.

Phil
----- Original Message -----
From: "Chris Snyder" <cs*****@chxo.com>
To: "NYPHP Talk" <ta**@lists.nyphp.org>
Sent: Thursday, July 31, 2003 1:36 PM
Subject: Re: [nyphp-talk] TCL, PHP and cookies - AUGH!

In fact, if $env(SERVER_NAME) works, I'd try $env(HTTP_COOKIE) and see
what it comes up with.

Chris Snyder wrote:
The key to finding the cookie in TCL might be the $env list?


_______________________________________________
talk mailing list
ta**@lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk


_______________________________________________
talk mailing list
ta**@lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk
Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Phil Powell" <so*****@erols.com> wrote in message
news:<tydWa.36$cf.33@lakeread04>...

In /cma/index.php, which sets the cookie:

setcookie('username', $username, time() + 600);
...
header("Location...");

It redirects to the TCL CGI /cma_main.cgi which in turns does NOT
see the cookie name "username" ever set.


Which is exactly what should be happening. Since you omitted
the optional 'path' argument, the cookie is set for the current
directory (in your case, /cma). When you try to read the cookie
from the root directory, nothing happens, because your cookie
is not set for the root directory...

It's all in the docs, read 'em:

http://php.net/setcookie

Cheers,
NC
Jul 16 '05 #2

P: n/a
Well, I added the path '/' to setcookie, to no avail. Same problem; Cookie
did not appear in the browser cookie file nor anywhere else, yet
$HTTP_COOKIE_VARS["username"] exists...

The PHP script is on a Linux server too BTW..

Phil

"Nikolai Chuvakhin" <nc@iname.com> wrote in message
news:32**************************@posting.google.c om...
"Phil Powell" <so*****@erols.com> wrote in message
news:<tydWa.36$cf.33@lakeread04>...

In /cma/index.php, which sets the cookie:

setcookie('username', $username, time() + 600);
...
header("Location...");

It redirects to the TCL CGI /cma_main.cgi which in turns does NOT
see the cookie name "username" ever set.


Which is exactly what should be happening. Since you omitted
the optional 'path' argument, the cookie is set for the current
directory (in your case, /cma). When you try to read the cookie
from the root directory, nothing happens, because your cookie
is not set for the root directory...

It's all in the docs, read 'em:

http://php.net/setcookie

Cheers,
NC

Jul 16 '05 #3

P: n/a
Try setting your browser to ask for confirmation before setting the
cookie (Mozilla is good for cookie management) and see if setcookie
really is working.

Additionally, confirm that your system clock is the same as the server
clock. Cookies will only be returned by the browser back to the script
if it thinks its not expired, so a system clock 10 minutes faster than a
server clock (or the other way round) will cause problems... :)

Phil Powell wrote:
Ok now it has turned to the bizarre.

In /cma/index.php, which sets the cookie:

setcookie('username', $username, time() + 600);
...
header("Location...");

It redirects to the TCL CGI /cma_main.cgi which in turns does NOT see the
cookie name "username" ever set. I go to my /Phil/Cookies folder for the
cookie under the "valsignalandet.com" domain and, sure enough, "username" is
not set. However, $HTTP_COOKIE_VARS["username"] DOES exist every time I go
to /cma/index.php thereafter, in spite of nothing else showing a cookie
exists.

So, in short, "setcookie()" in PHP is setting a nonexistent cookie.

Phil
----- Original Message -----
From: "Chris Snyder" <cs*****@chxo.com>
To: "NYPHP Talk" <ta**@lists.nyphp.org>
Sent: Thursday, July 31, 2003 1:36 PM
Subject: Re: [nyphp-talk] TCL, PHP and cookies - AUGH!
In fact, if $env(SERVER_NAME) works, I'd try $env(HTTP_COOKIE) and see
what it comes up with.

Chris Snyder wrote:

The key to finding the cookie in TCL might be the $env list?


______________________________________________ _
talk mailing list
ta**@lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk

_______________________________________________
talk mailing list
ta**@lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk


--
MeerKat

Jul 16 '05 #4

P: n/a
Hi,

I've the same problem on my LAMP Server.

I set the cookie with setcookie and path "/" in a directore /Logon.
Everything works fine within that directory (the cookie is found). But when
trying to get the cookie in f.e. /Events/Wedding it's not there (but set in
the browser).

This seems to be a problem for PHP Session management as well because
session_start() is also not identifying the session created in the /Logon
folder.....

regs
Volkmar

"MeerKat" <li****************@blueyonder.co.uk> wrote in message
news:UR*************@news-binary.blueyonder.co.uk...
Try setting your browser to ask for confirmation before setting the
cookie (Mozilla is good for cookie management) and see if setcookie
really is working.

Additionally, confirm that your system clock is the same as the server
clock. Cookies will only be returned by the browser back to the script
if it thinks its not expired, so a system clock 10 minutes faster than a
server clock (or the other way round) will cause problems... :)

Phil Powell wrote:
Ok now it has turned to the bizarre.

In /cma/index.php, which sets the cookie:

setcookie('username', $username, time() + 600);
...
header("Location...");

It redirects to the TCL CGI /cma_main.cgi which in turns does NOT see the cookie name "username" ever set. I go to my /Phil/Cookies folder for the cookie under the "valsignalandet.com" domain and, sure enough, "username" is not set. However, $HTTP_COOKIE_VARS["username"] DOES exist every time I go to /cma/index.php thereafter, in spite of nothing else showing a cookie
exists.

So, in short, "setcookie()" in PHP is setting a nonexistent cookie.

Phil
----- Original Message -----
From: "Chris Snyder" <cs*****@chxo.com>
To: "NYPHP Talk" <ta**@lists.nyphp.org>
Sent: Thursday, July 31, 2003 1:36 PM
Subject: Re: [nyphp-talk] TCL, PHP and cookies - AUGH!
In fact, if $env(SERVER_NAME) works, I'd try $env(HTTP_COOKIE) and see
what it comes up with.

Chris Snyder wrote:
The key to finding the cookie in TCL might be the $env list?

______________________________________________ _
talk mailing list
ta**@lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk

_______________________________________________
talk mailing list
ta**@lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk


--
MeerKat

Jul 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.