librelist archives

« back to archive

Best way to find a user online.

Best way to find a user online.

From:
kracekumar ramaraju
Date:
2011-11-04 @ 03:01
Hello

  I am creating Chat room application in flask. Now I need to keep track of
list of online users.

Approaches.

   1. Read list of recent messages stored in db and decide a person is
   online or not.
   2. Introspect with session file and find out the user is online or not.

I am looking to use second method, to implement it, between I was unable to
locate location of the file containing session of all users . I looked into
the code here.
https://github.com/mitsuhiko/flask/blob/master/flask/sessions.py

If there is a better way to implement this, please share the details.
-- 
*
"Talk is cheap, show me the code" - Linus Torvalds
Winning Regards
KraceKumar.R
http://kracekumar.wordpress.com
+91-97906-58304
*
*+91-85530-29521*
*
*

Re: [flask] Best way to find a user online.

From:
Simon Sapin
Date:
2011-11-04 @ 08:17
Le 04/11/2011 04:01, kracekumar ramaraju a écrit :
>  1. Read list of recent messages stored in db and decide a person is
>     online or not.
>  2. Introspect with session file and find out the user is online or not.
>
> I am looking to use second method, to implement it, between I was unable
> to locate location of the file containing session of all users . I
> looked into the code
> here.https://github.com/mitsuhiko/flask/blob/master/flask/sessions.py


Hi,

Sessions in Flask are actualy signed cookies stored on the client side. 
Since they are not stored on the server, you can not do that.

It is possible to switch to session backed by some data store on the 
server and do 2, but that sounds brittle.

Armin published a snippet a while ago on how to do that with Redis:
http://flask.pocoo.org/snippets/71/

Re: [flask] Best way to find a user online.

From:
kracekumar ramaraju
Date:
2011-11-04 @ 15:52
On Fri, Nov 4, 2011 at 1:47 PM, Simon Sapin <simon.sapin@exyr.org> wrote:

> Le 04/11/2011 04:01, kracekumar ramaraju a écrit :
> >  1. Read list of recent messages stored in db and decide a person is
> >     online or not.
> >  2. Introspect with session file and find out the user is online or not.
> >
> > I am looking to use second method, to implement it, between I was unable
> > to locate location of the file containing session of all users . I
> > looked into the code
> > here.https://github.com/mitsuhiko/flask/blob/master/flask/sessions.py
>
>
> Hi,
>
> Sessions in Flask are actualy signed cookies stored on the client side.
> Since they are not stored on the server, you can not do that.
>
> It is possible to switch to session backed by some data store on the
> server and do 2, but that sounds brittle.
>
> Armin published a snippet a while ago on how to do that with Redis:
> http://flask.pocoo.org/snippets/71/
>


I had gone through it, thought of implementing without using redis
previously. Any ways thanks :)

-- 
*
"Talk is cheap, show me the code" - Linus Torvalds
Winning Regards
KraceKumar.R
http://kracekumar.wordpress.com
+91-97906-58304
*
*+91-85530-29521*
*
*