PHPFusion\Authenticate::setUserCookie PHP Method

setUserCookie() public static method

Get user data when authenticating in user
public static setUserCookie ( $userID, $salt, $algo, $remember = FALSE, $userCookie = TRUE )
    public static function setUserCookie($userID, $salt, $algo, $remember = FALSE, $userCookie = TRUE)
    {
        global $_COOKIE;
        $cookiePath = COOKIE_PATH;
        $cookieName = COOKIE_USER;
        if ($remember) {
            $cookieExpiration = time() + 1209600;
            // 14 days
        } else {
            $cookieExpiration = time() + 172800;
            // 48 hours
        }
        if (!$userCookie) {
            $cookiePath = COOKIE_PATH;
            // also allow infusions admin.
            $cookieName = COOKIE_ADMIN;
            $cookieExpiration = time() + 172800;
            // 48 hours
        }
        $key = hash_hmac($algo, $userID . $cookieExpiration, $salt);
        $hash = hash_hmac($algo, $userID . $cookieExpiration, $key);
        $cookieContent = $userID . "." . $cookieExpiration . "." . $hash;
        //header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
        Authenticate::_setCookie($cookieName, $cookieContent, $cookieExpiration, $cookiePath, COOKIE_DOMAIN, FALSE, TRUE);
        // Unable to set cookies properly
        if (!isset($_COOKIE[COOKIE_VISITED])) {
            redirect(Authenticate::getRedirectUrl(3));
        }
    }