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 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Working with 2 cookies

    I have a site that allows people to create custom homepages.
    They can choose a theme and setup custom links. All of this info is saved to a cookie.

    So I guess what I want is to have a "defaultcookie" set when the user accesses the main page. Then when they set there own preferences the "defaultcookie" will be deleted, and the "usercookie" will be set.

    Now if they go back to the main page I need some sort of script to check to see if "usercookie" has been set. If it has, then do nothing. If it hasn't been set, then set "defaultcookie".
    Is this possible?
    Last edited by neobolt; 03-13-2009 at 04:40 PM.

  • #2
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    PHP Code:
    //if usercookie is not set
    if(!isset($_COOKIE['usercookie']))
    {
       
    //set the default cookie
       
    setcookie('defaultcookie''your value here'time()+3600);//this will expire in 1hr

    http://php.net/setcookie

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hey, thanks for the quick response. Awesome, I'll give it a shot.


  •  

    Posting Permissions

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