Flask Session
Session
- Session concept is similar to Cookie. The Session data is stored on Client.
- It is defined as the duration for which a user logs into the server and logs out.
- The data is used to track this session which is stored into the temporary dictionary on the server.
- A session with each client is assigned a Session ID.
- For encryption, a Flask application needs a defined SECRET_KEY.
Syntax
Session Pop
- pop() method - Used to remove the session variable.
Read Also
Sample code
Session Variable
Session Set
Login Application in the flask using Session
- This is a simple login application built using python flask that implements the session.
login.py
success.html
logout.html
- We will create a login application in the flask.
Session Home
- If we visit the login page then, the application shows the login page. The user enter the data email Id and password
Session Login
- Click the submit button. The user redirected to the success.html as given in the following image.
Session Sucess
- Now, visit the profile page. It will display the message with the session name as the session variable 'email' is set to its value.
Session Profile
- As we now logged in to the application. This application make easy to log out the session, for this purpose, go back to the home page click on the logout button. It will destroy all the session variables set for this particular server.
Session Logout
If you want to learn about Python Course , you can refer the following links Python Training in Chennai , Machine Learning Training in Chennai , Data Science Training in Chennai , Artificial Intelligence Training in Chennai