Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

object in session: Fatal error: Exception thrown without a stack frame in Unknown on line 0

session_start();
$_SESSION['dbo'] = NEW PDO('sqlite:database.db3');

gives:

Fatal error: Exception thrown without a stack frame in Unknown on line 0

but putting it to ordinary variable gives no error. All I try to do is to put object into session so it is initialized once.

like image 373
rsk82 Avatar asked Dec 08 '25 09:12

rsk82


1 Answers

Some objects cannot be serialized and stored in $_SESSION.

If your intent was to store a database connection in session for reuse, don't follow that undertaking: it doesn't work.

From PHP reference on serialize:

[...] serialize() handles all types, except the resource-type. You can even serialize() arrays that contain references to itself. Circular references inside the array/object you are serializing will also be stored. Any other reference will be lost.

like image 93
Linus Kleen Avatar answered Dec 10 '25 00:12

Linus Kleen