Sweet! I thought this went to the wayside. I've been using it too on my stuff 
with no problems. Do you think this could make it into the trunk soon? Here is 
the link to the proposal too
http://framework.zend.com/wiki/display/ZFPROP/Zend_Session_SaveHandler_DbTable
 
Thanks,
Jordan 
He that teaches himself hath a fool for his master. -- Benjamin Franklin
Poor is the pupil who does not surpass his master. -- Leonardo da Vinci.

----- Original Message ----
From: Simon Mundy <[EMAIL PROTECTED]>
To: Truppe Steven <[EMAIL PROTECTED]>
Cc: [email protected]
Sent: Saturday, September 22, 2007 7:10:53 PM
Subject: Re: [fw-general] using Zend_Auth with a custom Session Save Handler ?

The Zend_Session_SaveHandler_DbTable component is tucked away in the incubator 
- I've had it running now for the last couple of weeks in combination with 
Zend_Auth and it's been working wonderfully. It's been used in conjunction with 
a series of linked microsites using different subdomains and this approach has 
been the most effective way for me to manage sessions smoothly across them all 
(especially if I decide to offload my database and sessions to a standalone 
server down the track).

First you set up your session table. Here's my MySQL dump (nearly identical to 
the example shown on the proposal page for Zend_Session_SaveHandler_DbTable):-


CREATE TABLE `session_list` (
  `id` varchar(32) collate utf8_unicode_ci NOT NULL,
  `save_path` varchar(32) collate utf8_unicode_ci NOT NULL,
  `name` varchar(32) collate utf8_unicode_ci NOT NULL default '',
  `modified` int(11) default NULL,
  `lifetime` int(11) default NULL,
  `data` text collate utf8_unicode_ci,
  PRIMARY KEY  (`id`,`save_path`,`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci PACK_KEYS=1;


Here's an example of my config.ini file:-


[all]


; -----------------------------------------------------------------------------
; Database connection
; -----------------------------------------------------------------------------
db.connection = pdo_mysql
db.host = localhost
db.username = myusername
db.password = mypassword
db.dbname = mydatabase


; -----------------------------------------------------------------------------
; Session
; -----------------------------------------------------------------------------
session.cookie_domain = mydomain.com.au
session.name = mycustomsessionname
session.remember_me_seconds = 864000
session.use_only_cookies = on


sessionhandler.name = session_list
sessionhandler.lifetime = 864000
sessionhandler.primary = id
sessionhandler.dataColumn = data
sessionhandler.modifiedColumn = modified
sessionhandler.lifetimeColumn = lifetime
sessionhandler.overrideLifetime = true



This is how I set it up in my bootstrap:-


// Set up database
$db = Zend_Db::factory($config->db->connection, $config->db->toArray());
Zend_Db_Table::setDefaultAdapter($db);


// Set session defaults
Zend_Session::setOptions($config->session->toArray());
Zend_Session::setSaveHandler(new 
Zend_Session_SaveHandler_DbTable($config->sessionhandler->toArray()));


And then continue to use Zend_Auth as you would normally.


Note that the storage engine for Zend_Auth bears no relation to the session at 
all - this will be a completely separate table (if you're using database 
authentication).


Hope this gets you on the way!


Cheerio

Hi,

i have a class that implements Zend_Session_SaveHandler_Interface to
save the session data inside a database. now i want this save handler to
be used to store the identity after authentication.

in the manual i found this:

    /By default, Zend_Auth provides persistent storage of the identity
    from a successful authentication attempt using the PHP session. Upon
    a successful authentication attempt, Zend_Auth::authenticate()
    stores the identity from the authentication result into persistent
    storage. Unless configured otherwise, Zend_Auth uses a storage class
    named Zend_Auth_Storage_Session, which, in turn, uses Zend_Session.
    A custom class may instead be used by providing an object that
    implements Zend_Auth_Storage_Interface to Zend_Auth::setStorage()./

What does that mean for the Zend_Session_SaveHandler implementation ? Is
Zend_Auth_Storage_Interface the same interface ??


I only found Zend_Session::setSaveHandler() but i have no idea how to
use this in combination with Zend_Auth (because Zend_Auth handles
Zend_Session internal).

I hope someone can help me with this.

best regards,
Truppe Steven



 --


Simon Mundy | Director | PEPTOLAB


""" " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
http://www.peptolab.com


 







Reply via email to