Stefano Esposito wrote:
Hi all,
i've a self-defined class describing an user. In the login page i create an
instance of the user object and store it in $_SESSION['user']. When accessing
$_SESSION['user'] from other pages (of course I do require('user.php'); and
session_start();) i got this errors:
Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in
/home/httpd/html/uss_tyco3/user.php on line 390
Warning: user::get_unita_row() [function.user-get-unita-row]: Couldn't fetch
mysqli in /home/httpd/html/uss_tyco3/user.php on line 391
Fatal error: Call to a member function fetch_assoc() on a non-object in
/home/httpd/html/uss_tyco3/user.php on line 396
<snip code>
Any hint?
You are trying to store a resource (MySQLi connection) in the session.
This is not possible. You need to implement __sleep and __wakeup methods
in your class to properly close and re-create the connection on each
request. See here for more: http://php.net/oop5.magic
-Stut
--
http://stut.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php