<div dir="ltr"><font face="arial, helvetica, sans-serif">Thanks Bryan for this input. I used Flask-Session<b><a href="https://pythonhosted.org/Flask-Session/"> https://pythonhosted.org/Flask-Session/</a></b> to implement server side sessions in Redis. But I am running in to a issue (and this might very well be my mis understanding of session implementation). When I hit  /activate endpoint I set the session there as follows:</font><div><pre><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)">session[</span><font color="#008000"><b>user_id</b></font><font color="#000000">] = 'user'</font></font></pre><pre style=""><font color="#000000" face="arial, helvetica, sans-serif">user_id is sent by the app. After setting session here if I do a session.get(user_id) I get the value back but when I try to the same thing in          </font><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif">another endpoint /someother </span></pre><pre style=""><font face="arial, helvetica, sans-serif"><font color="#000000"><b>print session.get(user_id, 'not set')</b></font><span style="color:rgb(0,0,0)"> </span></font></pre><pre style=""><span style="color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif">I get 'not set'. Now in my understanding if this key was written to Redis then I should be able to       retrieve it from any endpoint. Please help   me figure this out if I am missing anything here. </font></span></pre><pre style=""><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)">Also in redis-cli when I do a <b>keys *</b> I see several </span><font color="#000000"><b>session:700b4e35-8c5c-4efb-bc6b-1c22b8e29ede, </b>doing a get on this I get <b>(dp1\nS'_permanent'\np2\nI01\ns.</b> I am assuming this in some internal implementation of flask sessions but is there a easier way from the redis-cli to see if   my key is getting set and retrieve its value?</font></font></pre><pre style=""><font face="arial, helvetica, sans-serif"><font color="#000000"><br></font></font></pre><pre style=""><font face="arial, helvetica, sans-serif"><font color="#000000">Thanks</font></font></pre></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 16, 2016 at 7:26 PM, Bryan Corralejo <span dir="ltr"><<a href="mailto:corralejob@gmail.com" target="_blank">corralejob@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">You could store the data in a session for the user. Flask-session offers an interface into  redis/memcached for server side sessions or you can store it in a session cookie and have the data sent with every request. </p>
<div class="gmail_quote"><div><div class="h5">On Jan 16, 2016 9:16 PM, "aiman parvaiz" <<a href="mailto:aimanparvaiz@gmail.com" target="_blank">aimanparvaiz@gmail.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi all<div><span style="color:rgb(34,36,38);font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;font-size:15px;line-height:19.5px">I am new to flask and am writing API for a simple video upload android app. App uses whatsapp like one time password authentication and the user stays logged in. App has user role and every user has a uuid associated with it. For every end point app sends a uuid to the server and I use that uuid to talk to the DB to get the role of the user. I want to skip this step of going to DB and getting the user role. I wanted to know what would be the best way to get the role from DB once and store it somewhere for all the subsequent user requests till this user logs out. In my limited knowledge flask.g won’t work beyond the first request by the user(As it is valid only for one request) and browser like sessions can’t be supported in the android app(we tried making requests from the app but session['id'] is not available for usage. Same code worked fine on a browser). Should I be looking in to storing a simple key:value in redis/memcahced or is there a better way to approach this issue. Also, I would be using uwsgi and nginx to host this backend.</span><br></div><div><br></div><div><font color="#222426" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">Any help would be appreciated please.</span></font></div><div><span style="color:rgb(34,36,38);font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;font-size:15px;line-height:19.5px">Thanks</span></div></div>
<br></div></div>_______________________________________________<br>
Flask mailing list<br>
<a href="mailto:Flask@python.org" target="_blank">Flask@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/flask" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/flask</a><br>
<br></blockquote></div>
</blockquote></div><br></div></div>