Question

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.

Was it helpful?

Solution

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'];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top