I am writting login system but when i click logout button website is opening same page.
<form action="out" method="POST">
<button type="submit" class="dropdown-item py-3 pr-5">logout</button>
</form>
server.js:
app.post('/out', function(request, response) {
request.session.destroy();
response.redirect('/');
});
app.get('/', function(request, response) {
if (request.session.loggedin) {
response.sendFile(path.join(__dirname + '/public/chat.html'));
} else {
response.sendFile(path.join(__dirname + '/public/index.html'));
}
});
Website every time opening chat.html but If I full refresh the site, web site opening index.html.