Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "factory"

Easier method to choose domain and path for session cookie

This is an easier method of setting variables for the session cookie. It available in versions above v0.6.3 (1.0 betas and higher). Examples assume your front application name is called "frontend".

config/frontend/factories.yml:

storage:
    class: sfSessionStorage
    param:
      session_name:            MYAPP_SESSION
      session_cookie_lifetime: 77760000   # 90*24*3600
      session_cookie_path:     /
#      session_cookie_domain:   localhost
#      session_cookie_secure:   true

Comment/Uncomment what you need. That is all, there is no need to create a custom class. You may need to clear symfony's cache.

by Todd Eddy on 2007-01-22, tagged cookie  domain  factory  session  storage 

How to choose domain and path for session cookie...

<?php
class mySessionStorage extends sfMySQLSessionStorage
{
    public function initialize ($context, $parameters = null)
    {
        session_set_cookie_params ( 90*24*3600 , "/", ".domain.tld" );
        parent::initialize($context, $parameters);
    }
}
?>

Then you have to put in factories.yml

all:
  storage:
    class: mySessionStorage
    param:
      database: ...
      db_table: session
      db_id_col: sess_id
      db_data_col: sess_data
      db_time_col: sess_time
      session_name: ...
by Romain Dorgueil on 2006-05-22, tagged cookie  domain  factory  session  storage 
(6 comments)