Results 1 to 5 of 5

Thread: Cookie prob

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Question Cookie prob

    Why does this code not work:
    PHP Code:
    {
    $checked=$_POST['checked'];
    $cookie_val=1
    if(isset($checked=='checked'))){
    set_cookie('BSComputers'$cookie_valtime()+(3600*24*365));
    } else {
    }; 

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Re: Cookie prob

    The objects 'checked' is a checkbox

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Cookie prob

    isset() can only be used with variables, it makes no sense with an expression as you have used.

    The snippet can be rewritten simply as
    PHP Code:
    if (isset($_POST['checked']) && (bool)$_POST['checked']) {
      
    set_cookie('BSComputers'1time() + 3600 24 365);


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Re: Cookie prob

    It doesn't really works...I don't understand what that (bool) is there for? How should the checkbox be named with this code?

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Cookie prob

    I assumed the checkbox was named "checked".

    (bool) is to convert the checkbox value into a boolean. It's not really necessary.

Posting Permissions

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



Click Here to Expand Forum to Full Width