Menu

setcookie()

2005-05-08
2013-06-03
  • tresloukadu

    tresloukadu - 2005-05-08

    I am getting the following error when trying to log in: 

    Warning: setcookie() expects parameter 3 to be long, string given in /home/helpdesk/public_html/includes/cookie.inc.php on line 8 

    The cookie.inc.php is actually quite a small file and I would not think that it would cause me much grief, but it is. Below is the actual code for the cookie generation script: 

    <?php 
    // Modified by Andrew Walker (ajwalker@home.com) 
    $time = mktime()+$g_cookietimeout; 
    $date = date("l, d-M-y H:i:s", ($time)); 

    if (isset($authentication)) { 
    setcookie("status", $status, $date); 
    setcookie("user", $user, $date); 
    setcookie("group", $group, $date); 
    setcookie("authentication", $authentication, $date); 
    setcookie("laston", $laston, $date); 

    else { 
    setcookie("status", "Logged In", $date); 
    setcookie("user", $txtUsername, $date); 
    setcookie("group", $row[4], $date); 
    setcookie("authentication", "YES", $date); 
    setcookie("laston", $row[6], $date); 

    ?> 

    Any help would be greatly appreciated.

     
    • tresloukadu

      tresloukadu - 2005-05-08

      the following code: $date = date($time); 

      does not seem  success on IE5.

      Any help would be greatly appreciated.

       
    • silasco

      silasco - 2006-01-11

      The problem is setcookie is looking for data of type 'long' where as the variables set to it are strings. That is why you are getting an error. I have php5. This is how i fixed the problem. I assume the original coder had a version of php that doesn't have a problem with the data format.

      $time = (mktime()+ $g_cookietimeout);
      $time = $time * 0;
      $date = date("l, d-M-y H:i:s", ($time));

      if (isset($authentication)) {
          setcookie("status", $status, $time);
          setcookie("user", $user, $time);
          setcookie("group", $group, $time);
          setcookie("authentication", $authentication, $time);
          setcookie("laston", $laston, $time);
      }
      else {
          setcookie("status", "Logged In", $time);
          setcookie("user", $txtUsername, $time);
          setcookie("group", $row[4], $time);
          setcookie("authentication", "YES", $time);
          setcookie("laston", $row[6], $time);
      }

      ?>

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.