tags:

views:

19

answers:

2

I need to know the best way to reduce the size of data to be stored in cookie.

A: 

You could store a unique identifier or token as the cookie's value and then store all the data you want associated with it on the server side in the database.

User shows up with token abcdefg. You query the db and get all your info for token abcdefg.

Michael Pryor
A: 

Also depends on the kind of data you want to store. You can express a subset of known, possibly applicable property values as 2 to the power of n, e.g.

Car Wash Properties:

Basic Air Dry 1
Hand wipe with chamois 2
Steam clean wheels 4
Steam clean engine 8
Hot Wax 16
Interior vacuum 32
Tire treatment 64

such that Basic Air Dry + Interior vacuum = 33. All you'd need to store is the value 33.

Tim