开发者

$_SESSION['user']->getURL()

开发者 https://www.devze.com 2022-12-25 08:44 出处:网络
$_SESSION[\'user\']->getURL() Is it to call the method of getURL开发者_JAVA百科() of object $_SESSION[\'user\']?
$_SESSION['user']->getURL()

Is it to call the method of getURL开发者_JAVA百科() of object $_SESSION['user']?


Is it to call the method of getURL() of object $_SESSION['user']?

Yes, that is how you would do it.


You can't really store objects in a session

I stand corrected:

You can store objects in the session... as long as the class is loaded (or can be autolated) by the time session_start() is called.

or you need to serialize and unserialize them in order to use them in a session.

You might also need a __wakeup function if the class requires a database connection.

http://php.net/manual/en/function.serialize.php

http://php.net/manual/en/function.unserialize.php

[edit]

You probably shouldn't be storing the user object in the session, possibly just an identifier so you can reinstantiate the user object when the page loads (that way the password is not stored in the $_SESSION if it is in the user object)


It retrieves the object stored in $_SESSION['user'] and calls its getURL method with no arguments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号