Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Cookie from home page VS deeper page

Status
Not open for further replies.

jerschab

Programmer
Apr 17, 2001
10
US
Hi. I am having trouble trying to set a cookie from a page within the hierarchy of the domain. However, if I place the code to set a cookie within the home page ( it works fine. Why am I having problems setting a cookie from a deeper page ( Although I have no experience setting cookies prior to this I think the concept is very simple. To keep it simple in testing I just called &quot;setCookie()&quot; from &quot;onLoad&quot; within the <body> tag and my setCookie function is so simple:

function setCookie(){
document.cookie=&quot;name=jeremy&quot;
}

Why is this not working from the deeper pages??
 
jerschab,

Try this...
Code:
function setCookie(){
document.cookie=&quot;name=jeremy;path=/&quot;
}
This will allow any page below (in hierarchy) the page that sets the cookie. You call it the same way as usual. Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
Unfortunately the &quot;;path=/&quot; method isn't doing anything - although I think I understand it (for reading cookies from other pages in the hierarchy really, right?). Do I have to set my cookie in the home page area only??? This can't be because webmonkey.com has a tutorial that sets a cookie on a really deep page. I still can't set this suckr from anything but the home page. Any more ideas?? Please...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top