-4

I don't know why but all of the sudden I started getting this error. I marked the line 37 in it. I am using xampp server. and below the full error line which I am getting. "Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting end of file in C:\xampp\htdocs\gallery\admin\includes\functions.php on line 19".

Please help me out in this.

<?php 


class Session {


    private $signed_in = false;
    public  $user_id;


    function __construct(){

        session_start();
        $this->check_the_login();
    }

    public function is_signed_in() {

        return $this->signed_in;

    }

    public function login($user){

        $this->user_id = $_SESSION["user_id"] = $user->id;
        $this->signed_in = true;
    }

    public function logout(){

        unser($_SESSION["user_id"]);
        unser($this->user_id);
        $this->signed_in = false;

    }

    private function check_the_login(); {  // This is line 37

        if (isset($_SESSION["user_id"])) {
            $this->user_id  = $_SESSION["user_id"];
            $this->signed_in = true;
        }else {

            unset($this->user_id);
            $this->signed_in = false;
        }
    }

}

$session = new Session();

 ?>
  • There is an extra semicolon (`;`) in line 37. Remove it and the error will disappear. Read about the syntax of [user-defined functions](http://php.net/manual/en/functions.user-defined.php) in PHP. – axiac Jul 03 '18 at 10:37
  • You have typo in this line. `unser($_SESSION["user_id"]);unser($this->user_id);` It should be `unset($_SESSION["user_id"]);unset($this->user_id);` – Virb Jul 03 '18 at 10:37

1 Answers1

0

try this

Remove ; after function name

private function check_the_login(); // remove ;

also error in logout() function

write unset instead of unser

unset($_SESSION["user_id"]);
unset($this->user_id);
Bhargav Chudasama
  • 6,928
  • 5
  • 21
  • 39