Check if session doesn't exist php

php, session

Solution

Try with `$_SESSION` like

<?php 
   if (!isset($_SESSION) || !isset($_SESSION['password']) || !isset($_SESSION['user_name'])) {
         header("Location: ../../"); /* Redirect browser */
   }
?>

Problem

I have the following php code : ``` <?php if (!(session_id('password')) || !(session_id('user_name'))) { header("Location: ../../"); /* Redirect browser */ } ?> ``` Which should check if session doesn't exist, and if it doesn't, the user redirects, the problem is that this condition is always true, even when the session does exists, my question is how can I fix it?

Original source