Mehmet Kagan Kayaalp
Mehmet Kagan Kayaalp

Reputation: 565

Send a post request to server

I am fairly new in web development and I decided to handle a user's availability to send a POST request to server. However, I do not know even whether it is possible or not but when a user close my Django site without using logout button (For example close the browser or tab), in order to understand the user is offline or online, I want to send a request to server. As a result, when the server does not get an answer from the user for a while, it automatically logout the user.

Can you tell me is it a good way to handle a user's availability and first of all is it a realistic solution? If it is, can you suggest me a document or example that helps me please.

Upvotes: 0

Views: 198

Answers (2)

Rodrigo López
Rodrigo López

Reputation: 227

I agree to to the answer of @Mounir. That's not related to django, if you want to know when a user is "disconnected"(close the tab or window) you need to use javascript, in concrete you need to use Sockets.

I recommend you this ones: http://socket.io/

https://github.com/centrifugal/centrifugo

I'm using centrifugo for one project right now. In concrete, for chat and inbox messaging. It's very simple to make it run with Django.

Greetings

Upvotes: 2

Mounir
Mounir

Reputation: 11726

For logging out user you can use the Session expiration, but for all other staff you want to achieve I don't see any thin really related to Django itself, everything depend on your requirements and is more Browser/javascript related than Django.

Upvotes: 1

Related Questions