Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session object instances different. Is this correct?

I have written a shopping cart application with a shopping cart object being stored in the http session. On each request I'm returned a different object instance. Is this the expected behaviour?

If I modify my shopping cart object, do I need to store it in the session again every time (at the moment my changes are lost because I'm not doing this)?

Works fine in development but not live. Is this to because of the distributed architecture of GAE or am I doing something wrong?

I really hope you can help or confirm my thoughts on this. Thanks in advance.

Chris

p.s. i'm using struts2, but don't know if that is possibly a problem

like image 875
Chris at GroovyFly.com Avatar asked Aug 08 '26 10:08

Chris at GroovyFly.com


1 Answers

Yes, due to the session not necessarily being stored in memory, your session values will be copies, not references to the same objects.

From the GAE docs;

Because App Engine stores session data in the datastore and memcache, all values stored in the session must implement the java.io.Serializable interface.

In other words, GAE will serialize/deserialize your sessions as needed, generating copies.

like image 102
Joachim Isaksson Avatar answered Aug 09 '26 23:08

Joachim Isaksson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!