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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2007
    Location
    Back On The Right Coast
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    First cookie wins

    I have a working cookie setting script. I don't want to replace an existing unexpired cookie. How can I start the script to test for the existence of an unexpired cookie, and then not set a cookie if an unexpired cookie exists? I don't really know PHP, so all help is appreciated.

    Thanks,
    Steve

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    PHP Code:
    if(!isset($_COOKIE['cookiename']))
    {
        
    setcookie('cookiename''data');


  • #3
    New to the CF scene
    Join Date
    Oct 2007
    Location
    Back On The Right Coast
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thank you Inigoesdr!

    Like I said I don't know PHP, so forgive me if this questions seems basic. It seems that the logic sets a cookie if a cookie exists. I want the opposite. Am I misreading this? If I am misreading this, should I replace setcookie('cookiename', 'data') with my cookie script?

    Steve
    Last edited by steveorg; 11-14-2007 at 09:37 PM.

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by steveorg View Post
    It seems that the logic sets a cookie if a cookie exists. I want the opposite. Am I misreading this?
    Yes, you're misreading it. The exclamation point in front of the function tells the logic to look for the opposite.
    Quote Originally Posted by steveorg View Post
    If I am misreading this, should I replace setcookie('cookiename', 'data') with my cookie script?
    Yes.

  • Users who have thanked Inigoesdr for this post:

    steveorg (11-16-2007)

  • #5
    New to the CF scene
    Join Date
    Oct 2007
    Location
    Back On The Right Coast
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    This is perfect. Thanks so much for your help.


  •  

    Posting Permissions

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