library/core/class.cookieidentity.php
public static function SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires, $Path = NULL, $Domain = NULL, $CookieHashMethod = NULL, $CookieSalt = NULL) {
      
      if (is_null($Path))
         $Path = Gdn::Config('Garden.Cookie.Path', '/');

      if (is_null($Domain))
         $Domain = Gdn::Config('Garden.Cookie.Domain', '');

      // If the domain being set is completely incompatible with the current domain then make the domain work.
      $CurrentHost = Gdn::Request()->Host();
      if (!StringEndsWith($CurrentHost, trim($Domain, '.')))
         $Domain = '';
   
      if (!$CookieHashMethod)
         $CookieHashMethod = Gdn::Config('Garden.Cookie.HashMethod');
      
      if (!$CookieSalt)
         $CookieSalt = Gdn::Config('Garden.Cookie.Salt');
      
      // Create the cookie signature
      $KeyHash = self::_Hash($KeyData, $CookieHashMethod, $CookieSalt);
      $KeyHashHash = self::_HashHMAC($CookieHashMethod, $KeyData, $KeyHash);
      $Cookie = array($KeyData, $KeyHashHash, time());
      
      // Attach cookie payload
      if (!is_null($CookieContents)) {
         $CookieContents = (array)$CookieContents;
         $Cookie = array_merge($Cookie, $CookieContents);
      }
      
      $CookieContents = implode('|',$Cookie);

      // Create the cookie.
      setcookie($CookieName, $CookieContents, $CookieExpires, $Path, $Domain, NULL, TRUE);
      $_COOKIE[$CookieName] = $CookieContents;
   }
public static function SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires, $Path = NULL, $Domain = NULL, $CookieHashMethod = NULL, $CookieSalt = NULL) {
      
      if (is_null($Path))
         $Path = Gdn::Config('Garden.Cookie.Path', '/');

      if (is_null($Domain))
         $Domain = Gdn::Config('Garden.Cookie.Domain', '');

      // If the domain being set is completely incompatible with the current domain then make the domain work.
      $CurrentHost = Gdn::Request()->Host();
      if (!StringEndsWith($CurrentHost, trim($Domain, '.')))
         $Domain = '';
   
      if (!$CookieHashMethod)
         $CookieHashMethod = Gdn::Config('Garden.Cookie.HashMethod');
      
      if (!$CookieSalt)
         $CookieSalt = Gdn::Config('Garden.Cookie.Salt');
      
      // Create the cookie signature
      $KeyHash = self::_Hash($KeyData, $CookieHashMethod, $CookieSalt);
      $KeyHashHash = self::_HashHMAC($CookieHashMethod, $KeyData, $KeyHash);
      $Cookie = array($KeyData, $KeyHashHash, time());
      
      // Attach cookie payload
      if (!is_null($CookieContents)) {
         $CookieContents = (array)$CookieContents;
         $Cookie = array_merge($Cookie, $CookieContents);
      }
      
      $CookieContents = implode('|',$Cookie);

      // Create the cookie.
      setcookie($CookieName, $CookieContents, $CookieExpires, $Path, $Domain, NULL, TRUE);
      $_COOKIE[$CookieName] = $CookieContents;
   }
public static function SetCookie ( $ CookieName , $ KeyData , $ CookieContents , $ CookieExpires , $ Path = NULL , $ Domain = NULL , $ CookieHashMethod = NULL , $ CookieSalt = NULL ) { if ( is_null ( $ Path ) ) $ Path = Gdn :: Config ( 'Garden.Cookie.Path' , '/' ) ; if ( is_null ( $ Domain ) ) $ Domain = Gdn :: Config ( 'Garden.Cookie.Domain' , '' ) ; // If the domain being set is completely incompatible with the current domain then make the domain work. $ CurrentHost = Gdn :: Request ( ) -> Host ( ) ; if ( ! StringEndsWith ( $ CurrentHost , trim ( $ Domain , '.' ) ) ) $ Domain = '' ; if ( ! $ CookieHashMethod ) $ CookieHashMethod = Gdn :: Config ( 'Garden.Cookie.HashMethod' ) ; if ( ! $ CookieSalt ) $ CookieSalt = Gdn :: Config ( 'Garden.Cookie.Salt' ) ; // Create the cookie signature $ KeyHash = self :: _Hash ( $ KeyData , $ CookieHashMethod , $ CookieSalt ) ; $ KeyHashHash = self :: _HashHMAC ( $ CookieHashMethod , $ KeyData , $ KeyHash ) ; $ Cookie = array ( $ KeyData , $ KeyHashHash , time ( ) ) ; // Attach cookie payload if ( ! is_null ( $ CookieContents ) ) { $ CookieContents = ( array ) $ CookieContents ; $ Cookie = array_merge ( $ Cookie , $ CookieContents ) ; } $ CookieContents = implode ( '|' , $ Cookie ) ; // Create the cookie. setcookie ( $ CookieName , $ CookieContents , $ CookieExpires , $ Path , $ Domain , NULL , TRUE ) ; $ _COOKIE [ $ CookieName ] = $ CookieContents ; }
Set a cookie, using specified path, domain, salt and hash method

@param string  $CookieName Name of the cookie
@param string  $KeyData
@param mixed   $CookieContents
@param integer $CookieExpires
@param string  $Path Optional. Cookie path (auto load from config)
@param string  $Domain Optional. Cookie domain (auto load from config)
@param string  $CookieHashMethod Optional. Cookie hash method (auto load from config)
@param string  $CookieSalt Optional. Cookie salt (auto load from config)
@return void
Set a cookie using specified path domain salt and hash method