0

I just discovered that when I configure the session plugin of a Catalyst app (Catalyst::Plugin::Session) to expire, it screws with the flash data. More specifically, I'm finding that flash data no longer carries over with a new request.

Does this sound normal? How might I cope with this?

4

2 回答 2

5

Perfectly normal. The whole point of sessions is to be able to associated data from one request with data in another request. When you let the session for some request expire, you are saying that that request's data shouldn't have anything to do with any future request.

More specifically, the flash data is a part of the session data -- see the _save_flash method in the Catalyst/Plugin/Session.pm file, for instance. Also see the big warning for the delete_session method:

NOTE: This method will also delete your flash data.

How to cope with it? You need to persist data from a request using any scheme other than the Session plugin. Without knowing more about your app, what data you are trying to persist, and how you will associate data from an old session with a new request, I couldn't begin to make a more specific recommendation than that.

于 2012-04-16T22:16:44.543 回答
2

When configuring the session for example with a database backend you'll have to add flash_to_stash as an option:

<session>
  dbi_dbh            DB
  dbi_table          sessions
  dbi_id_field       id
  dbi_data_field     session_data
  dbi_expires_field  expires
  flash_to_stash     1
  expires            3600
</session>
于 2012-04-16T22:17:18.183 回答