We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Get session in independent file.

in public_html, i create independent file myfile.php for do something.

in this file, i want to get session which users have logged.

i'm try to start session:

<?php
session_start();
if($_SESSION["login"]):
   //do something
else:
  //do another
endif;
?>

i get a error

<?php
Warning: Class __PHP_Incomplete_Class has no unserializer in
?>

What's a solution for me ? Thank all so much.



4.0k

I guess, you stored object in $_SESSION["login"]. Try include the class that is stored in $_SESSION["login"].

I guess, you stored object in $_SESSION["login"]. Try include the class that is stored in $_SESSION["login"].

i have loginController/indexAction for user login.

//if success
$this->session->set("login", "1");

In independent file, i var_dump($_SESSION["login"]), i get object

Warning: Class __PHP_Incomplete_Class has no unserializer in E:\local\htdocs\gl\domain.com\123.php on line 2
object(__PHP_Incomplete_Class)#1 (1) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(17) "Models\Glang\User"
}


4.0k
edited Jul '15

"login" has Models\Glang\User object. Maybe old data? Maybe overided session login parameter. Try clear session.