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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    read and write cookies without reloading

    Hi, Im making a script, where a cookie is loaded and written on a place, but if the cookie is not on the users computer, I make it on the page using
    Code:
    setcookie ("cookie", "the text of the cookie", time()+3600);
    and later in the page I want the cookie to be loaded in a specific place.
    But ther problem is that the cookie is not loaded without the page is being refreshed, is there a solution for something like this?
    Greetz

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try something on these lines

    myCookie=getCookie("cookie")

    if(!myCookie){
    myString="the text of the cookie"
    setCookie("cookie", myString, time()+3600)
    }
    else{
    myString=getCookie("cookie")
    }

    You can then reference the variable myString later in the page
    Last edited by Mr J; 08-08-2006 at 09:35 PM.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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