login with php session

0

I would like when I get to the login page only a user with a certain login would enter the error when I access

php code:

if($_SESSION['login'] == 'admin')
{
echo "logado";
}

It gives error in the part of the session in if, as if it did not have.

    
asked by anonymous 14.03.2017 / 17:47

1 answer

3

You have to put a condition for when you enter it to verify that the session exists, try:

if(isset($_SESSION['login']))

will probably resolve

    
14.03.2017 / 17:48