Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Compressing data structures for cookies

by Herkum (Parson)
on May 08, 2007 at 23:15 UTC ( [id://614272]=note: print w/replies, xml ) Need Help??


in reply to Compressing data structures for cookies

There are too many limitations when you use cookies to store data. There are size limits, it reduces the responsiveness of the client and it is just not secure.

That is why people are going to tell you over and over that you need to use CGI::Session. Once you learn it you will be eternally grateful for it.

  • Comment on Re: Compressing data structures for cookies

Replies are listed 'Best First'.
Re^2: Compressing data structures for cookies
by gwg (Beadle) on May 09, 2007 at 07:28 UTC

    I'm already using a local variant of CGI::Session to store data server-side. The problem is that there are two machines which run the program, and a user could be directed to either of the two (the sys admin says that each user is usually sent to the machine they were previously on, but it can't be guaranteed every time). The other thing is that the volume of users is such that it is not feasible to keep the session data for every person, and it would be better for users to be able to have their settings persist between sessions.

    I just re-checked the maximum size of the data structure as the original estimate had extra unneeded info in it; it's 402 bytes (as a file), and most user settings would probably be half that.

      If you are using CGI::Session with a database, having multiple machines would not be a problem. The reason for this is that the user would just a Session ID cookie. The session ID would correspond with a primary key on a 'sessions' table in the database. The database would contain all user settings and can store whatever information that they need for the duration of the session.

      All you would have to do is point both web services to the same database where the session data is stored. Now it would not matter which server you go to and you can add a third or a fourth server, etc... and you would not have to change anything.

      This would also apply to data as well. You can expand the number of user settings from your 402 bytes to 3 or 4 KB and you not have to change anything.

      The other thing is that the volume of users is such that it is not feasible to keep the session data for every person

      You have to keep the data somewhere. You stated that currently that the settings take up 402 bytes. Than means 1 MB can store settings for 2600 users. That is not much storage space at all.

      , and it would be better for users to be able to have their settings persist between sessions.

      If the data is persistent and is not needed for a particular session then store it in a table. You need someway of identifying the user, create a 'user' table and put everything in there.

      Databases are not a limitation, they can manage thousands and even millions of records and gigs of data.

      Cookies are what are limiting, move away from using them so much.

                              /- prog 1  -\
      client - load balancer -            - database
                              \- prog 2  -/
      
      

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://614272]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found