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
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cookies stored on localhost

    Hello PPl,

    I would like to know if cookies are stored when testing website on localhost?

    The problem I am having is when I view the site locally my cookie script is finding two different values for the same cookie. I think its taking one value from the 'local cookie' and the other from when I view the site on a 'LIVE' host (internet).

    I have tried to delete all the cookies but the problem is still there. I am using Win2K and use php pages with an Apache Server. The code to set cookies, delete cookies and get cookies are JavaScript and not PHP.

    Many thanks

    -Habib
    Last edited by habib; 10-21-2003 at 09:02 AM.

  • #2
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any ideas?

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Cookies are depending on the domain - so if you are loading the document from a different domain, it will nto have access to the cookies it set on the other domain. And localhost is not only another domain but an entirely different protocol (I guess you mean localhost as in using the file protocol), unless you have a local server running from which you load the file.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thankyou for replying...

    Cookies are depending on the domain so if you are loading the document from a different domain, it will nto have access to the cookies it set on the other domain
    From this, my understanding is that if a user logged onto www.mydomain.com - a cookie is created with this domain, and if a user accesses www.mydomain.co.uk - a different cookie would be created and the values from the .com cookie would not be used. Is there any code I can use to set or retrieve data from cookies from a specific domain and ignore all else?

    Regards
    Habib

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,965
    Thanks
    0
    Thanked 236 Times in 233 Posts
    you can only retrieve the cookie that matches the current document's domain with the cookie's domain attribute.

    http://wp.netscape.com/newsref/std/cookie_spec.html

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    You can SET a cookie for another domain, however. Whether the browser accepts it depends on the settings and the user.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ok...

    So if I wanted to set a cookie for any domain name that contained 'mydomain' and only use the values from this cookie - would this be possible?

    For example...

    I have purchased lots of domain names - (they all have the same) -

    mydomain.com
    mydomain.net
    mydomain.org
    mydomain.co.uk and so on....

    If a user enters my site using '.com' a cookie is set, the user leaves the site and at a later date returns to my site but this time the user uses '.co.uk' - I want to use the values from the '.com' cookie for this user.

    Is this possible?

    -Habib

  • #8
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    No. You have to set the cookie explicitly for each domain you want.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #9
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok,

    Thankyou very much for your help and support.

    -Habib

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,965
    Thanks
    0
    Thanked 236 Times in 233 Posts
    if you have subdomains like below:

    a.b.c.mydomain.com
    x.y.z.mydomain.com
    g.mydomain.com
    h.i.mydomain.com

    you can set the cookie domain as ".mydomain.com" so that the cookie is visible to all subdomains with that domain.


  •  

    Posting Permissions

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