rsk82
rsk82

Reputation: 29397

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.

Upvotes: 3

Views: 2882

Answers (1)

Linus Kleen
Linus Kleen

Reputation: 34642

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.

Upvotes: 6

Related Questions