Tuesday, September 29, 2009

Symfony 1.2 User sessions and sfGuard

Symfony automatically manages user sessions and is able to keep persistent data between requests for users. It uses the built-in PHP session-handling mechanisms and enhances them to make them more configurable and easier to use.

Symfony's session-handling feature completely masks the client and server storage of the session IDs to the developer. However, if you want to modify the default behaviors of the session-management mechanisms, it is still possible. This is mostly for advanced users.

On the client side, sessions are handled by cookies. The symfony session cookie is called symfony, but you can change its name by editing the factories.yml configuration file, as shown


all:   
  storage:     
    class: sfSessionStorage    
    param:       
      session_name: my_cookie_name

in factories.yml


On the server side, symfony stores user sessions in files by default.

Session expiration occurs automatically after 30 minutes. This default setting can be modified for each environment in the same factories.yml configuration file, but this time in the user factory, as shown

all:   
  user:    
    class:       myUser     
    param:       
      timeout:   1800   # Session life in sec

No comments:

Post a Comment