Forum Moderators: coopster

Message Too Old, No Replies

Cookies

Need help with 2 questions regarding cookies.

         

Alina

4:08 pm on Apr 29, 2003 (gmt 0)

10+ Year Member



I am fixing some web stuff for a client and as i am new to the job, have 2 questions regarding cookies.

1. If my PHP code has a "setcookie (Test, $val);" - where would this cookie be located on my C drive using windows98? Would the cookie be called "Test"?. I tried looking for Test in C:\WINDOWS\Cookies and in C:\WINDOWS\Temporary Internet Files - but could not see the cookie anywhere.

2. If my PHP code on a domain-A server calls a "setcookie (Test, $val);", and then hrefs to a booking form on a secure domain-B server, would the value of cookie Test be lost between domains? If this is so, how may i keep the value of Test intact?

Many thanks for any help received,

Alina

Birdman

4:16 pm on Apr 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe the cookie's location will vary dependent upon the browser being used. Just recall the cookie after setting it to be sure it was indeed set.

No, you can't access the cookie from another domain, but you can send the values along with the url in a querystring.

domainb.com/page.php?Test=$val1

Alina

11:04 am on Apr 30, 2003 (gmt 0)

10+ Year Member



Birdman, Thank you very much for the information.

netcommr

11:42 am on Apr 30, 2003 (gmt 0)

10+ Year Member



Hi Alina,

Q1 - Birdman is right, browsers will usually store the cookies in their program folders. IE will put them in the Internet temp folder and cookies folder. The cookie will be named with the user account on your local computer at the time and the domain from where it came from. Such as, local_user_account@other_domain.com (usually)

Your data (Test, $val) will be stored in the cookie which you can view with a text editor like notepad.

Q2 - Yes, the cookie will not transfer between secure and unsecure communication, even on the same domain. You must retrieve the cookie data from the users computer and transmit it with the request to secure server B. Server B must then be able to handle this data with the request. Several ways to do this, such as have your links to the secure server go to a script on server A which grabs the cookie and appends the data to the url then forwards the request to a script on server B to seperate the data from the url then forwards your request to the right page. Javascript can be used in the web page on sever A to get the cookie data and append to urls in the html document in place of the forwarding script on server A. But, you still need a way to seperate the data from the url on server B.

** Remember, cookies are only sent by the user during a request to a page. The server can not request them, only place them.