I have a database storing users, with their attributes : pseudo, password...
When a user is connecting to my web application, I go to the database and I search the user. With setFetchMode(PDO::FETCH_CLASS, 'User')
, I have directly the result in a PHP object, as an instance of the User
class. I store it in $_SESSION['user']
.
When a user is subscribing to my web application, I insert him in the database. I would like to have the user in $_SESSION['user']
. So I would like to have access to the inserted field as a PHP object, without searching again this user. Is my question clear, and do you know how to do please ?
I think the best solution for you would be too add make a SELECT
request just after your insert (with the proper PDO flags to load an User
object.