javascript cookie

Discussion in 'JavaScript' started by freddie.aziz, Aug 14, 2011.

  1. #1
    I'm trying to implement javascript cookies here..

    <script type="text/javascript">
    function setCookie(KNwidget,fbfans,1);
    
    if (function getCookie(KNwidget))
      {
      }
    else
      {
      jQuery(document).ready(function(){
      
        jQuery.lightbox("index.php?test=show-this-when-no-cookie");
    
      });
      }
    </script>
    Code (markup):
    what's the problem with this code?? can u help me fix this please?
     
    freddie.aziz, Aug 14, 2011 IP
  2. programmer_best1

    programmer_best1 Well-Known Member

    Messages:
    282
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    133
    #2
    function SetCookie(cookieName,cookieValue,nDays);
    so is fbfans variable or value ?? ... you have to make it "fbfans" if its a value.

    and i think you got problem with your if statment
    make it like this:-
    
    if (getCookie(KNwidget))
    
    Code (markup):
    good luck
     
    programmer_best1, Aug 15, 2011 IP
  3. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #3
    you're calling a function the wrong way, it should be...

    <script type="text/javascript">
    setCookie(KNwidget,fbfans,1);
    
    if (getCookie(KNwidget))
    ...
    </script>
    HTML:
     
    JohnnySchultz, Aug 16, 2011 IP
  4. freddie.aziz

    freddie.aziz Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thank tou.. :D I understand with your explanation now..
     
    freddie.aziz, Aug 18, 2011 IP