From the manual
Note: It is currently impossible to register resource variables in a session. For example, you cannot create a connection to a database and store the connection id as a session variable and expect the connection to still be valid the next time the session is restored. PHP functions that return a resource are identified by having a return type of resource in their function definition. A list of functions that return resources are available in the resource types appendix.
If $SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, assign values to $SESSION. For example: $_SESSION['var'] = 'ABC';