[appengine-java] Re: Single session per user

2011-02-27 Thread Scott
Thanks for the response Didier!

I know I can store the session id, but how do I then retrieve the
session object by id? I have been looking at ways to access
_ah_SESSION entities using the low level datastore api like this:

   DatastoreService ds =
DatastoreServiceFactory.getDatastoreService();
   com.google.appengine.api.datastore.Query q = new
com.google.appengine.api.datastore.Query(_ah_SESSION);

I can set a filter to return a single object matching a key value, but
is the session id the key value? This is difficult to test, because it
seems the _ah_SESSION entities are not created on the dev server.

I have also read that session objects could be stored in the memcache.
I have been trying this as well using the following code:

MemcacheService ms =
MemcacheServiceFactory.getMemcacheService();
ms.get(?);

I am again not certain what to use for the key value in the ms.get()
call. I know the key is prefixed with _ahs, but I don't know the rest.
Is this prefix appended to the session id in some way? This is also
difficult to test on the dev server, because the sessions don't seem
to be stored in the memcache.

Does anyone know the difference in session management on the dev
server vs the production server?

Thanks,
Scott



On Feb 27, 2:15 am, Didier Durand durand.did...@gmail.com wrote:
 Hi,

 Yes, the simplest way is to store the session id in the datastore.

 You can get a session id via javax.servlet.http .HttpSession.getId();

 regards

 didier

 On Feb 26, 7:51 pm, Scott shathaw...@gmail.com wrote:







  Howdy,

  I want to only allow my users to have a single session at a time. The
  act of logging in should invalidate a session that might have been
  created from another devices as well as sending that device a notice
  via the channel that the session had ended.

  I actually had this working on my dev server. I used a singleton to
  hold a copy of the session object and channel information, and when
  the user logged in from a different device, I would invalidate and
  send a message. The problem is that since GAE the production server is
  distributed, I have no guarantee of the same JVM on each call.

  Reading through docs and group post, the only possibility I could
  think of was to retrieve the session object from the datastore or
  memcache. Is it possible to read the session object from the either of
  these locations? If so what is the key and object type?

  Thanks a lot,
  Scott

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Single session per user

2011-02-26 Thread Didier Durand
Hi,

Yes, the simplest way is to store the session id in the datastore.

You can get a session id via javax.servlet.http .HttpSession.getId();

regards

didier

On Feb 26, 7:51 pm, Scott shathaw...@gmail.com wrote:
 Howdy,

 I want to only allow my users to have a single session at a time. The
 act of logging in should invalidate a session that might have been
 created from another devices as well as sending that device a notice
 via the channel that the session had ended.

 I actually had this working on my dev server. I used a singleton to
 hold a copy of the session object and channel information, and when
 the user logged in from a different device, I would invalidate and
 send a message. The problem is that since GAE the production server is
 distributed, I have no guarantee of the same JVM on each call.

 Reading through docs and group post, the only possibility I could
 think of was to retrieve the session object from the datastore or
 memcache. Is it possible to read the session object from the either of
 these locations? If so what is the key and object type?

 Thanks a lot,
 Scott

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.