Reputation: 796
I am using FOSUserBundle to manage users, and sessions are saved in database thanks to PdoSessionStorage.
I would like to add fields in my session table :
Here is my app/config/config.yml file :
framework:
session:
default_locale: %locale%
auto_start: true
lifetime: 72000
storage_id: session.storage.pdo
parameters:
pdo.db_options:
db_table: session
db_id_col: session_id
db_data_col: value
db_time_col: time
services:
doctrine.dbal.default.wrapped_connection:
factory_service: doctrine.dbal.default_connection
factory_method: getWrappedConnection
class: PDO
session.storage.pdo:
class: Symfony\Component\HttpFoundation\SessionStorage\PdoSessionStorage
arguments: [@doctrine.dbal.default.wrapped_connection, %session.storage.options%, %pdo.db_options%]
How can I do that ?
Do I need to extend PdoSessionStorage class ?
If so, how to do this ?
Upvotes: 1
Views: 1166
Reputation: 5882
Simply extend PdoSessionStorage
to add your infos. You are free to add any dependency to the session.storage.pdo
.
About the User ID, you don't have to do it, it's already in the session data (you will have to decode them).
Upvotes: 2