PHP - Sessions and cookies

1

I have a page login.php which after being filled goes to processa.php and then enters the session and cookie:

$cookie_name = "Administrador";
$cookie_value = $id;
setcookie($cookie_name, $cookie_value, time() + (3600), "/");
$_SESSION['user'] = $id;
header("Refresh: 0; url=MENU/menu.php");

And on the login.php page, I wanted to do something like this, if the user who has already logged in, wants to go back to the site, and goes to login, login checks to see if the session still exists and send it to returns to menu.php . I did it this way but it does not seem to work:

<? 
session_start();

if(!isset($_SESSION['user']))
    {
        setcookie("Administrador");
        session_destroy();
    }else
    {
        $user = $_SESSION['user'];
        header("MENU/menu.php");
    }
?>
    
asked by anonymous 12.04.2016 / 22:23

1 answer

0

You can use the PHP header function

header("Location: http://www.seusite.com.br");
  

More details here: php header function

    
12.04.2016 / 22:43