I want to maintain state in my Perl web app. How can I do this effectively? I looked at CGI::Session but it says that it doesn’t work well with UTF-8 pages, which is a requirement. I’d also like to be able to pass some basic information to another Java application running on the Glassfish app server, so people aren’t forced to login to both apps, for example. How can all this be managed?
Share
The basics of sessions are that you need a place to hold the session data (the store) and a way to store and retrieve the session data. While some frameworks call that The State, it really boils down to having a session key (or session ID) and passing it back to your app via either a cookie or a URL parameter.
Your store can be anything that can hold the data for you. Some examples are: a flat file, a dbm file, a DBMS,or an in-memory cache of some type.
The most common implementation, which is used by CGI::session and Apache::Session is to have three fields in each record inside the store: session_id,session_data, expires_time.
The session modules on the CPAN take care of loading your session at the beginning of the request, and storing it back at the end.