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 1 of 1
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    215
    Thanks
    52
    Thanked 1 Time in 1 Post

    help with setting and reading cookies?

    Hi;
    I have a site with a cms system written in custom php and javascript/html
    These pages and scripts are located in directory under the content that it
    is supposed to manage.
    The cms interface page is secured by scripts and sets a cookie to read to
    screen each logged in request ( it is not using https.)

    What I want to do is have the cookie set and be able to read it from a
    page in the directory above where it is set. This is so I can block access
    to the public content while admin and revision is going on, but not block
    access to the client with the right cookie.
    I have been using document.cookie('var=value;path=/;domain=localhost') -- ( localhost is dev server).
    But when I open preference panel in Firefox to read the cookies, it shows none.
    Whereas if I just write document.cookie(var=value) it works. But I cannot read the cookie in a page in
    the directory above it.
    Do I have to set the time values also? Or what?

    editing: I finally got the right syntax and variable values. It should have been domain=local network address
    for local dev server. The dev server is not on the same machine as the client, in which case it would be 'localhost'
    so I use php to get the server name and print the value to a javascript value in the head script and use that as
    the cookie value ( - www. or whatever )
    Last edited by anotherJEK; 03-09-2014 at 11:23 PM. Reason: solution found


 

LinkBacks (?)

  1. 03-11-2014, 01:02 PM

Posting Permissions

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