jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

I was wondering what folks favorite way to maintain state is? I am making a preview function for a content management script and the data can be lengthy like here on PM. The thing is the format of the page doesn't lend itself to having the form fields repeated like we do it here. I am sure I can't use cookies as the data could easily exceed the 4 Kb limit. So I'm assuming I'll have to go the hidden field route. All opinions welcomed!
TIA
jg
_____________________________________________________
If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ

Replies are listed 'Best First'.
(Ovid) Re: Polling All Monks: Favorite Ways To Maintain State
by Ovid (Cardinal) on Jan 16, 2002 at 06:11 UTC

    Why would the cookie data need to exceed 4Kb in length? Brand their browser and use the cookie brand to identify the state information that you store in a database. You can read about this from one of merlyn's columns.

    If you are concerned about clients that don't allow cookies, this makes it more difficult as you will need to parse all of the hyperlinks and add the session brand there (or add it to hidden fields in forms).

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: Polling All Monks: Favorite Ways To Maintain State
by jryan (Vicar) on Jan 16, 2002 at 11:25 UTC
    Give Apache::Session with a cookie used as an id indentifier a try. It was a bit of a pain to get installed, but after I got it working, it was well worth it.
Re: Polling All Monks: Favorite Ways To Maintain State
by simon.proctor (Vicar) on Jan 16, 2002 at 14:38 UTC
    In my current project I have written a state module that takes a hash of info, Data::Dumper's it, Crypt::TripleDES encrypts it and then mime encodes it. It also does the reverse to get the data structure back.

    I then pass this back to my main app for dealing how I want. Currently I am storing an ID and a timeout. I use the ID in the program to fetch more info - much like the branding that Merlyn was talking about further up this node.

    I am using the timeout as a means of providing an inactivity flag. I haven't finished implementing this yet but the idea is to allow someone to be deactivated if they walk away from their browser. I didn't want to rely on cookie timeouts as this then ties me to a single session solution.

    Slightly OT but the EU almost banned cookies over here. Obviously this was never going to happen but beurocrats love to meddle :).

    The kind of interface I am using for my session object is as follows:

    addToSession() getFromSession() _buildSession() clearSession session() toString() <------- called via overload key() <------- for the encryption (obviously :P)


    I didn't use anything like Apache::Session simply because I had to ensure it would work with IPlanet, Apache and IIS for the content management system I'm building at work.

    Hope that helps.
      I didn't use anything like Apache::Session simply because I had to ensure it would work with IPlanet, Apache and IIS for the content management system I'm building at work.
      Apache::Session and it's addon, Apache::SessionX both have no dependency on Apache.
Re: Polling All Monks: Favorite Ways To Maintain State
by shotgunefx (Parson) on Jan 16, 2002 at 11:41 UTC
    Can you be a little more specific?

    -Lee

    "To be civilized is to deny one's nature."
A reply falls below the community's threshold of quality. You may see it by logging in.