Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SetCookie & GetCookie in different Directory

    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()))+((pa th==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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

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

    Thanks,
    Jerome

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Whammy,

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

    The question is how.....

    Jerome

  • #6
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    do you pass a path when calling SetCookie? I think you should not pass a path.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    try:
    SetCookie(cookiename,cookievalue,null,"/")
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Merci beaucoup!

    Hi,

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

    Thanks,
    Jerome


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •