How to write and read array from cookies ?
The easiest way to write an array in cookie is serialize it using pickle module and quote returned string with urllib module. For example:
import pickle, urllib
cookie = []
response.set_cookie('some_cookie', urllib.quote(pickle.dumps(cookie)))
And getting an array from cookie:
cookie = pickle.loads(str(urllib.unquote(request.cookies['some_cookie'])))
0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment