473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Odd cookie behavior

I'm processing a form, and on the target posting page, I'm setting
cookies for the name/value pairs like this:

while (list($name, $value) = each($HTTP_POST_VARS))
{
if ( $value <> NULL ) {
setcookie($name,$value,time()+3600*24*30*12*10);
$mystring = "<input type=\"hidden\" value=\"$value\" name=\"$name\">\n
$mystring";
}
}

Now after posting when I go back to my original form with the same URL
path,

www.mydomain.com/mypath,

I can see that the cookies are there because the values appear in the
fields like we'd expect. However if I put the very same form in a
different directory, eg: www.mydomain.com/secondpath then the cookied
values no longer appear.

I knew that cookies could be domain specific, but is there a setting
that makes them somehow directory specific??

Thanks,

Chuck

Jan 10 '06 #1
3 1156

Chuck W. wrote:
I'm processing a form, and on the target posting page, I'm setting
cookies for the name/value pairs like this:

while (list($name, $value) = each($HTTP_POST_VARS))
{
if ( $value <> NULL ) {
setcookie($name,$value,time()+3600*24*30*12*10);
$mystring = "<input type=\"hidden\" value=\"$value\" name=\"$name\">\n
$mystring";
}
}

Now after posting when I go back to my original form with the same URL
path,

www.mydomain.com/mypath,

I can see that the cookies are there because the values appear in the
fields like we'd expect. However if I put the very same form in a
different directory, eg: www.mydomain.com/secondpath then the cookied
values no longer appear.

I knew that cookies could be domain specific, but is there a setting
that makes them somehow directory specific??

Thanks,

Chuck


Not sure about this, but have a look at the PATH - paramet:
http://php.net/setcookie

Jan 10 '06 #2
That was certainly it, thanks!!

Jan 10 '06 #3

Chuck W. wrote:
That was certainly it, thanks!!


Glad to help.

Jan 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Phil Powell | last post by:
Fourth attempt.. it fails now in login, I check by printing $_COOKIE and there is no value there! Guys, what on earth do I do about this???? Here is the code that sets the cookie: if...
5
by: AHN | last post by:
Please tell me somebody what causes the cookie set with <% Response.Cookies("blah") = "Blah blah" Response.Cookies("blah").Expires = DateAdd( "h", 1, Now() ) %> work as supposed on my local...
18
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page...
4
by: Shannon Jacobs | last post by:
I'm doing some trivial surveys, and I want to know if the same user answers twice. Can't really know that, but at least I thought I could check for the same browser/computer combination by using a...
3
by: HorseGeek | last post by:
I can't find a cookie that my code is writing. The behavior of my webpages indicates that the cookie IS being written SOMEPLACE. However, I can't find it. My client does not want the code going...
1
by: JJ_377 | last post by:
What is the reason for the difference between the way Netscape 7.1 (NS) makes a cookie and Internet Explorer 6 (IE) makes one in the following case: The following JavaScript cookie assignment...
3
by: Ben | last post by:
I'm having problems with cookies from asp.net to asp back to asp.net. It seems like I can set a cookie in asp.net fine, and alter it at will, as soon as asp touches it, asp.net won't have...
3
by: rss | last post by:
SUMMARY: ========== I am unable to pass along a simple Cookie obtained from a HttpWebRequest call (Machine A's ASP.NET app) so that another Web Server (Machine B) recongnizes the cookie. I...
1
by: tshad | last post by:
I am trying to write out and update my cookies, but it doesn't seem to work correctly. I am using the following code: if (passwordSaveCookie.checked) then If Request.Cookies("User") is nothing...
2
by: arijitdas | last post by:
Hi, We have an ASP.NET 2.0 web application where we want to share few user specific data between server and client side code using cookie. We are seeing a very strange behavior that it does not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.