-1

I used Flask's g variable to store variables. I hosted the app in IIS, the values are not working correct and some time previously edited values were shown. Then I moved to sessions to hold my data. In my case I should not use database for storing my data. For each session I have more than 10 variables. Whether it is good to hold the data in session? or storing variables globally across request is good in production environment, if yes, anyone please explain? Also I would like mention that global declaration of variables not working correct in production environment for me.

Sindhu S
  • 1
  • 1

1 Answers1

1

I am using flask for a long time and the session approach works great for me. Still, there are some security concerns because you are storing information in your session cookie which is easy to decrypt. If the data are not sensitive like passwords I strongly suggest using session.

  • Thanks for your response. Holding data in session working good. But The hosted application is working too slow if I use session. That's why I'm searching for alternatives. – Sindhu S Nov 24 '21 at 10:04
  • Well, you could include your variables in the HTML with input hidden. But still, are you sure that session slowing your app down? – Ioannis Skaltsas Nov 24 '21 at 10:09
  • In local, application is not slow. but in other machines which are connected in LAN application is slow compared to local. – Sindhu S Nov 24 '21 at 10:23
  • If we are talking about a LAN app mind clearing the cookie every time a new session is initialized. Not sure if this is going to help but give it a try. – Ioannis Skaltsas Nov 24 '21 at 10:27
  • while initiating a session, I'm not manually setting cookies. how to get rid of this? – Sindhu S Nov 24 '21 at 10:53
  • Just clear your session before you declare your routes in your app.py – Ioannis Skaltsas Nov 24 '21 at 11:12