From the course: Full Stack Web Development with Flask

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Setting up the session for logout and enrollment routes

Setting up the session for logout and enrollment routes - Flask Tutorial

From the course: Full Stack Web Development with Flask

Setting up the session for logout and enrollment routes

- Setting up the session for the logout and enrollment routes. In this video, we'll be creating the logout route and then we'll be setting up sessions for both the logout and enrollment routes. Let's go see how that's done. We need to implement a function called the logout. We have the login, but what about the logout. We can do it right here, and it will be very simple, app.route. This'll be a /logout, when that happens, then we're going to do a function called logout, and all we have to do is, we only have to have two sessions, so session['user_id']=false. You can do that or you can do session.pop and then here we'll put the username and then you pass in None, so either one, I think both should work, and then we're going to redirect the user back to the homepage, then url_for then index. Okay, that is it for the logout, very, very simple, and then the register right here, we did that already, for the redirect, so…

Contents