HELP in !

Discussion in 'PHP' started by minhazikram, Jan 14, 2012.

  1. #1
    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?
     
    minhazikram, Jan 14, 2012 IP
  2. waynewex

    waynewex Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should provide your entire session class so that others can check your other class functions
     
    waynewex, Jan 15, 2012 IP
  3. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #3
    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.
     
    mfscripts, Jan 18, 2012 IP