Storing objects in PHP session

后端 未结 5 2143
悲&欢浪女
悲&欢浪女 2020-11-29 02:24

The PHP documentation says \"You can\'t use references in session variables as there is no feasible way to restore a reference to another variable.\"

Does this mean

5条回答
  •  情歌与酒
    2020-11-29 02:47

    Your code example isn't using references as the documentation was referring to. This is what php means by references:

    $var =& $GLOBALS["var"];
    

    As to putting objects into the session, PHP can store objects in $_SESSION. See http://example.preinheimer.com/sessobj.php.

    What you are seeing is a bug in the order of calls to __sleep and __destruct (__destruct is being called before __sleep) and the session module fails to serialize the object at shutdown. This bug was opened on Sep 1, 2009.

提交回复
热议问题