tags:

views:

232

answers:

1

It's possible to store user session in database by changing the settings in factories.yml:

all:
  storage:
    class: sfMySQLSessionStorage
    param:
      db_table:    session              # Name of the table storing the sessions
      database:    propel               # Name of the database connection to use
      # Optional parameters
      db_id_col:   sess_id              # Name of the column storing the session id
      db_data_col: sess_data            # Name of the column storing the session data
      db_time_col: sess_time            # Name of the column storing the session timestamp

From the example given, it seems that the columns in the table are limited to a few predefined ones. Which means that it's not possible to store other information that Symfony doesn't anticipated, such as ip address.

Is it possible to extend the database schema to include more custom columns?

A: 

Not directly; the structure of a session is very limited, though you can store quite a bit of data within the session. Symfony just stores the session data as a blob in the db. You could try modifying the sfMySQLSessionStorage class to include the $_SERVER['REMOTE_IP'] in the session table if you really need it.

digitala