public static function encodeSecureCookie($value, $expires, $secret, $algorithm, $mode)
    {
        $key = hash_hmac('sha1', $expires, $secret);
        $iv = self::get_iv($expires, $secret);
        $secureString = base64_encode(self::encrypt($value, $key, $iv, array(
            'algorithm' => $algorithm,
            'mode' => $mode
        )));
        $verificationString = hash_hmac('sha1', $expires . $value, $key);

        return implode('|', array($expires, $secureString, $verificationString));
    }
public static function encodeSecureCookie($value, $expires, $secret, $algorithm, $mode)
    {
        $key = hash_hmac('sha1', $expires, $secret);
        $iv = self::get_iv($expires, $secret);
        $secureString = base64_encode(self::encrypt($value, $key, $iv, array(
            'algorithm' => $algorithm,
            'mode' => $mode
        )));
        $verificationString = hash_hmac('sha1', $expires . $value, $key);

        return implode('|', array($expires, $secureString, $verificationString));
    }
public static function encodeSecureCookie ( $ value , $ expires , $ secret , $ algorithm , $ mode ) { $ key = hash_hmac ( 'sha1' , $ expires , $ secret ) ; $ iv = self :: get_iv ( $ expires , $ secret ) ; $ secureString = base64_encode ( self :: encrypt ( $ value , $ key , $ iv , array ( 'algorithm' => $ algorithm , 'mode' => $ mode ) ) ) ; $ verificationString = hash_hmac ( 'sha1' , $ expires . $ value , $ key ) ; return implode ( '|' , array ( $ expires , $ secureString , $ verificationString ) ) ; }
Encode secure cookie value

This method will create the secure value of an HTTP cookie. The
cookie value is encrypted and hashed so that its value is
secure and checked for integrity when read in subsequent requests.

@param string $value     The unsecure HTTP cookie value
@param int    $expires   The UNIX timestamp at which this cookie will expire
@param string $secret    The secret key used to hash the cookie value
@param int    $algorithm The algorithm to use for encryption
@param int    $mode      The algorithm mode to use for encryption
@param string
Encode secure cookie value