Пример #1
0
 function setSessionAndCookie($_userId)
 {
     //se souvenir de moi
     $rememberMe = isset($_POST["chkConnection"]) ? $_POST["chkConnection"] : "";
     $_SESSION["id"] = $_userId;
     $_SESSION["role"] = Users::isUserAdmin($_userId) ? ROLE_SYSADMIN : (Users::isUserFamilyOwner($_userId) ? ROLE_FAMOWNER : (Users::isUserMod($_userId) ? ROLE_MOD : ROLE_USER));
     if (!empty($rememberMe)) {
         $tokenCode = self::generateCode(32);
         Users::deleteCookieToken($_userId);
         Users::setCookieToken($_userId, $tokenCode);
         setcookie("userToken", $tokenCode, time() + 86400 * 7, "/");
     }
 }