...

View Full Version : SetCookie & GetCookie in different Directory



Jerome
10-27-2002, 02:37 PM
Hi,

I SetCookie with:

function SetCookie(name,value){var argv=SetCookie.arguments;var argc=SetCookie.arguments.length;var expires=(argc>2)?argv[2]:null;var path=(argc>3)?argv[3]:null;var domain=(argc>4)?argv[4]:null;var secure=(argc>5)?argv[5]:false;d.cookie=name+"="+escape(value)+((expires==null)?"":(";expires="+expires.toGMTString()))+((path==null)?"":(";path="+path))+((domain==null)?"":(";domain="+domain))+((secure==true)?";secure":"");}

This cookie is set in the following directory:

C/level1/level2/level3/index.htm

After I want to GetCookie in the following directory:

C/level1/level2/index.htm

Problem:

GetCookie doesn't work, however when I place GetCookie in directory level3, level 4 or higher it works.

Question:

Where in the function SetCookie do I need to change the path-name in order to make GetCookie to work.

Thanks in advance,
Jerome

scroots
10-27-2002, 04:54 PM
jerome i maybe wrong but i don`t think you can, as it would be a big security breach having servers/computers being able to access folders on other peoples hard drives.

scroots

Jerome
10-27-2002, 05:12 PM
Hi,

It's the same domain, only a deeper directory!

Thanks,
Jerome

whammy
10-27-2002, 05:41 PM
When you set it, you specify it using path... you want path=/; so it specifies the root directory. Not sure exactly how to do it with the cookie code you posted though...

Jerome
10-27-2002, 07:45 PM
Hi Whammy,

It is exactly how You say, I want the Cookie Set in the root directory!

The question is how.....

Jerome

Jerome
10-28-2002, 08:48 AM
Hi,

I looked everywhere on the net, but unfortunately I didn't find the solution for my question, does anyone have an idea?

Thanks in advance,
Jerome

glenngv
10-28-2002, 09:35 AM
do you pass a path when calling SetCookie? I think you should not pass a path.

Jerome
10-28-2002, 10:01 AM
Hi,

When setting a cookie without pre-defining a specific - path - the path of the cookie is the directory structure where the document with -SetCookie - is placed f.e.

The code SetCookie is placed within hello.htm

hello.htm can be found under: C/level1/level2/level3/

The path of the cookie as seen in the temp I-net files or in cookies (HD) will be: C/level1/level2/level3/

In order to GetCookie in another level of the directory-structure I would like to SetCookie with path = root e.g. only the domain-name.

Thanks for replying,
Jerome

glenngv
10-28-2002, 10:24 AM
try:
SetCookie(cookiename,cookievalue,null,"/")

Jerome
10-28-2002, 12:09 PM
Hi,

Using: SetCookie(cookiename,cookievalue,exp,"/")
You can specify the path, starting from Your domain-name!

Thanks,
Jerome



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum