java - Session not working on GAE server, only locally -
i have google app engine (java) project i'm trying use sessions. in appengine-web.xml file have
<sessions-enabled>true</sessions-enabled>
. have userendpoint class has api method called "login". if user that's trying login app legit create session inside method:
httpsession session = req.getsession(); session.setattribute("userid", new longbean(user.getid().longvalue()));
the longbean object serializable , looks like:
public class longbean implements serializable { private static final long serialversionuid = 8041280664162299553l; private long longvalue; public longbean(long longvalue) { this.longvalue = longvalue; } public long getlongvalue() { return longvalue; } public void setlongvalue(long longvalue) { this.longvalue = longvalue; } }
. now, have api method in endpoint called insertscore. there check if session not null , has correct "userid" attribute. signature method is:
public userscore insertscore( httpservletrequest req, score score) throws notfoundexception, forbiddenexception
and
object userid = req.getsession().getattribute("userid");
. problem userid object null when project deployed on google's servers. makes more infuriating works locally. i've searched stackoverflow issue , answers i've found session has serializable longbean object seralizable! explain why works on localhost not on server?
edit: info: can see in datastore viewer session created , inserted _ah_session table in datastore.
adding
auth = @apiauth(allowcookieauth = annotationboolean.true)
to @api annotation in endpoint allows jsessionid cookie sent on wire, fixing issue.
Comments
Post a Comment