I have problems with PDO in OOP and its serializable security.
I want to save my session of the object but I get:
Fatal error: Uncaught PDOException: You cannot serialize or unserialize PDO
The problem is that if I serialize it outside of the object, I am exposed to attacks with Object injection.
I'm thinking, as soon as the "new" object is called, save a session inside it (and retrieve it) and destroy it (when the session ends) every "n" minutes.
Without having to call
$object = new ExampleObject ();
$_SESSION['serialize'] = serialize ($object) // security issues
$_SESSION['unserialize'] = unserialize ($object) // security issues
Let the ExampleObject automatically create the session. Is there any way to do it? If possible, could you show a basic example?
Note: I am trying to protect an object that is a connection PDO to mysql.