index.php

session_start() class Boo{ public $pub=100; } $obj=new Boo; $array=array("name"=>"fozi",189); $types=serialize($array); $obj_ser=serialize($obj); $_SESSION['obj']=$obj_ser; $_SESSION['arr']=$types; 

mother.php

 session_start(); class Boo{ public $pub=100; } $obj=unserialize($_SESSION['obj']); $arr= unserialize($_SESSION['arr']); echo $arr[0]; echo $obj->pub; 

Reading the documentation:

If an application uses sessions and the session_register () function to register objects, these objects are automatically serialized at the end of each PHP page execution, and de-serialized automatically at the start of each of the following pages. This means that these objects can appear on any of the pages of the application, once they become part of a session. However, the session_register () function is removed in PHP 5.4.0.

I understand correctly that you can access objects without this serialization? How?

    1 answer 1

    You can, if you write like this:

     $obj=new Boo; session_register("obj"); 

    But this feature is deprecated from 5.4.0.
    http://www.php.net/manual/ru/function.session-register.php

    • one
      So they write there: $ _SESSION ['obj'] = $ obj; this is normal and no need to be worn out. - zb '
    • eicto is generally wonderful. Thanks a lot ReinRaus ♦, eicto. - SverxnovA pm