News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1255448597:v:use_geshi-1:v:type-php

Started by Guest, Oct 13, 2009, 03:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Guest

//bool setcookie  ( string $name  [, string $value  [, int $expire = 0  [, string $path  [, string $domain  [, bool $secure = false  [, bool $httponly = false  ]]]]]] )
function set_cookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = false, $httponly = false)
{
   // This function is pointless if we have PHP >= 5.2.
   if (version_compare(PHP_VERSION, '5.2', '>='))
      return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);

   // $httponly is the only reason I made this function. If it's not being used, use setcookie().
   if (!$httponly)
      return setcookie($name, $value, $expire, $path, $domain, $secure);

   // Ugh, looks like we have to resort to using a manual process.
   header('Set-Cookie: '.rawurlencode($name).'='.rawurlencode($value)
      .(empty($domain) ? '' : '; Domain='.$domain)
      .(empty($expire) ? '' : '; Max-Age='.$expire)
      .(empty($path) ? '' : '; Path='.$path)
      .(!$secure ? '' : '; Secure')
      .(!$httponly ? '' : '; HttpOnly'), false);
}