Can't pass mysqli connection in session in php -


I am trying to pass a session with mysqli connection to multiple queries on the site, but when I do a query I try to do this, warns "mysqli could not be brought"

  $ _ session ['db'] = new mysqli ($ host, $ user name, $ password, $ Db);  

Is it possible to undergo a mesculine connection reference during the session? Is there a different method to use it?

Yes, this is clearly impossible.

See mentioned in the highlighted warning: "Some types of data can not be sorted in sessions, in which resource variables or objects are circular references (i.e. objects that references on another object Passes through). "

MySQL connections are such a source.

You have to reconnect on every page running again.

It is not as bad as it seems, if you can rely on connection pooling, but first see more background information in mysql_pconnect ().


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -