Re: Cookie-question?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---- Original Message ----- 
  From: Jose Miguel 
  To: Gustav Wiberg 
  Cc: PHP General 
  Sent: Thursday, September 08, 2005 3:26 AM
  Subject: Re:  Cookie-question?


  Ok, please correct me if i'm wrong...

  First of all, i'd rather use $_COOKIE instead of $HTTP_COOKIE_VARS.

  And in the line...

  if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

  Why don't you use the operator NOT IDENTICAL (!==), cause != will also return true if the variables are the same type sometimes.


  On 9/7/05, Gustav Wiberg <gustav@xxxxxxxxxxxxxx> wrote:
    Hi there! 

    Look at following code below, and please give me a clue why this
    cookie-thing doesn't work?
    $IDJoke is set before and is an ID from a row in a db
    It seems to work a while, but is there a limit for the expire-parameter? 

    /G
    http://www.varupiraten.se/


    //Get cookie from users computer for current joke to tell if user is
    allowed to vote or not!
        //
        $cookieJoke = $HTTP_COOKIE_VARS["$IDJoke"]; 
        if ($cookieJoke == 'voted') {$showVoteValues ='N';$userVote = 'N';}

        //User wants to vote?
        //
        if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

                $showVoteValues = 'N'; //Don't show values directly after
    vote...

                //Save IDJoke to a cookie with the value - voted to users
    computer
                setcookie("$IDJoke", 'voted', time()+60*60*24*30*12*100);  /*
    expires in about 100 years*/

        //END User wants to vote
        //
        }

    --
    PHP General Mailing List (http://www.php.net/ )
    To unsubscribe, visit: http://www.php.net/unsub.php





  -- 
  Jose Arce
  http://sinexion.com - http://josearce.com 


------------------------------------------------------------------------------


  No virus found in this incoming message.
  Checked by AVG Anti-Virus.
  Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06

  Hi

  Ok, Thanx for the input! :-)

  /G
  http://www.varupiraten.se/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux