I have a code like <?php if(!$session->is_logged_in()){ redirect_to('panel.php');} ?> here $session is an instance of the Session class and is_logged_in() is a method i.e a public method in the Session class here is a bit of code provided class Session{ private $logged_in; public $user_id; function __construct() { session_start(); $this->check_login(); } public function is_logged_in() { return $this->logged_in; } when is open the page by providing the url like localhost/../..admin/panel.php which contains the: <?php if(!$session->is_logged_in()){ redirect_to('panel.php');} ?> the page donot open in the browser window bbut when i remove the ! from the: <?php if(!$session->is_logged_in()){ redirect_to('panel.php');} ?> then the page opens. Can any one tell me that is <?php if(!$session->is_logged_in()){ redirect_to('panel.php');} ?> a wrong expression?
Try a bit of debugging, like this... First whether $session->is_logged_in() work fine: if(!$session->is_logged_in()){ die('Not logged in!'); } If you can see the message then it's fine. The try and see if it's the redirect function without the clause: redirect_to('panel.php'); One of them is probably failing.