문제

I am new to PHP. I want to implement PHP session manually. On a PHP pageload, I will check if cookie is set. If yes, I will display the required information, and if not, I will ask user to enter his details and then display the information. But I am not allowed to use PHP Sessions. I can use Cookies. Also the information needed to be displayed is about all the users (browsers) who are in session (so I have to save this to some static global array). Any help is appreciated. Thanks.

도움이 되었습니까?

해결책

try this

setcookie('cookie_name', 'cookie_value', time());
echo $_COOKIE['cookie_name'];

Now check the cookie if it exists.

if(isset($_COOKIE['cookie_name'])) {
    echo "your cookie is set";
} else {
    echo "return error or any thing you want";
}

This will give you all browser(s) information.

echo $_SERVER['HTTP_USER_AGENT'];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top