Limit the session number of single user with POST /{db}/_session api by sync gateway rest api?

36 views
Skip to first unread message

atom992

unread,
May 5, 2015, 5:46:00 PM5/5/15
to mobile-c...@googlegroups.com
Hi,all
I can get HTTP/1.1 200 OK response with Set-Cookie: SyncGatewaySession=***** and authentication_handlers info.
and when I call this api again, I can get another SyncGatewaySession info.
so my question is how can I limit the session‘s number per user? such as one user can only get one session? does sync gateway has some session management method?

Adam Fraser

unread,
May 5, 2015, 6:44:53 PM5/5/15
to mobile-c...@googlegroups.com
There's currently no built-in functionality in Sync Gateway to limit the number of active sessions per user, as far as I know.  

Jens Alfke

unread,
May 5, 2015, 7:42:30 PM5/5/15
to mobile-c...@googlegroups.com

> On May 5, 2015, at 2:45 PM, atom992 <yangzi...@gmail.com> wrote:
>
> so my question is how can I limit the session‘s number per user? such as one user can only get one session?

What are you trying to accomplish by doing this? (You might have a good reason, but I can't think of why you'd want to.)

—Jens

atom992

unread,
May 6, 2015, 11:41:14 PM5/6/15
to mobile-c...@googlegroups.com
I want to use custom auth of sync gateway by sync gateway REST api (not sync gateway admin REST api).
I want my app can works fine even offline. so if user logout offline, sync gateway don't know that user has logout. so when user login online, the sync gateway will return another session of this user. the old session will still in memory of sync gateway until expire time reached.

Adam Fraser

unread,
May 7, 2015, 4:31:23 PM5/7/15
to mobile-c...@googlegroups.com
I'm afraid I still don't grasp how creating a new session (when the user comes online) is problematic for your use case.  As you say - the old session is still accessible until it expires, but it shouldn't be introducing any functional issues for the new session.  

Is this solely a performance consideration?  If so, have you seen performance overhead related to the number of sessions being created?  There shouldn't be any memory/CPU overhead from the Sync Gateway side, and I wouldn't have anticipated issues solely based on the additional session documents being stored in the bucket. 
Reply all
Reply to author
Forward
0 new messages