I made a simple cookie and i want to store a python stack object.
C = Cookie.SimpleCookie()
arr = []
class Test:
num = None
for x in range(10):
test = Test()
test.num = x
arr.append(test)
C['myCookie'] = arr # i want to do something like this
arr = C['myCookie']
can any one tell me a way to do it . to store an array in python cookie
For general purpose object-to-string-and-back conversions, you could use the pickle module:
Keep in mind that unpickling untrusted cookies represents a security risk. If that is an issue for you, then you will need to adopt some other strategy for turning an array of user defined object into a string and for converting it back.