Re: State-keeping modules
by Tanktalus (Canon) on Mar 02, 2005 at 18:52 UTC
|
I would not recommend rolling your own until you've at least tried the existing modules and figured out how they failed to meet your requirements. There are trials and tribulations that have been ensconced within those modules - and rolling your own will merely mean rediscovering those issues. Since they will very likely both be acceptable to your requirements (not that those requirements are entirely clear - winning a popularity contest should not be the sum total of your requirements), pick the one that has the API that you find easier.
(For the record, I use CGI::Session, and have also written a back-end driver for it for use with the database that I use.)
| [reply] |
Re: State-keeping modules
by TedYoung (Deacon) on Mar 02, 2005 at 18:27 UTC
|
I have been using CGI::Session for several years, through dozens of projects and am very happy with it. It is quite flexible, and when used with storable is quite fast. However, I have never used Apache::Session and cannot compare the two.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
| [reply] [d/l] |
Re: State-keeping modules
by saberworks (Curate) on Mar 02, 2005 at 19:13 UTC
|
We have been using Apache::Session for a few months now and for some reason we are running into a fairly persistent problem: the session->DESTROY method isn't being called automatically all the time (only sometimes) so any time we start running into session issues, we have to throw a tied(%$sess)->DESTROY(); call. The symptoms: variables seem to randomly fail to get recorded to the session or deleted from the session when the script is finished running.
The other programmer I work with thinks it's our convoluted scripts confusing perl's garbage collector. | [reply] [d/l] |
|
I, very often, have the same problem with CGI::Session (which will flush on DESTROY if you haven't done it explicitly). In my case too it is likely something I have done else where. I just have found it easier to explicitly flush the session at the end of the request, than to debug what I am doing.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
| [reply] [d/l] |
|
To amplify on TedYoung's reply, this mentions doing the flush manually, just to be sure.
| [reply] |
Re: State-keeping modules
by jdtoronto (Prior) on Mar 02, 2005 at 19:26 UTC
|
| [reply] |
Re: State-keeping modules
by perrin (Chancellor) on Mar 03, 2005 at 00:05 UTC
|
You might want to look at Apache::SessionManager if you're using mod_perl. It handles a lot of the details for you. The persistence is done with Apache::Session. | [reply] |
|
| [reply] |
|
Not really. Both modules have problems, but both are now actively maintained.
| [reply] |
|
|
Re: State-keeping modules
by borisz (Canon) on Mar 02, 2005 at 19:16 UTC
|
| [reply] |
Re: State-keeping modules
by snookmz (Beadle) on Mar 02, 2005 at 19:57 UTC
|
I have not used CGI::Session or Apache::Session, but I have written a fairly simple module for maintaining state without cookies.
What I do is create a unique ID string, parse the html before it's outputted and tack it on to the end of any link. All ID's are tracked from a Mysql database, but they needn't be and could be kept in temp files.
That is a simplified explanation of what my module actually does, but as the implementation of stateful sessions over http seemed fairly straight forward I didn't even think to see if there was a module pre-written for it. | [reply] [d/l] [select] |
|
Sure, that's not a bad idea, but what happens when someone book marks the link? What about somebody copying the url and passing it to a friend? What about storing the link in an online bookmark type site? What about pasting it to a forum or something to share it?
| [reply] |
|
I use CGI::Session to maintain state in my applications. I also tack the CGISESSID value onto the end of each url in case a user does not have cookies enabled.
I understand your comment on bookmarking and linking problems with session-id-appended urls, but am not sure if there are any other ways to deal with browsers with cookies turned off, or user agents with no cookie capability. Any suggestions? (I'm open to other options from what I am using at the moment for those reasons outlined)
| [reply] |
|
| [reply] |