How a few lines of code greatly improved a crucial part of UX
blog.self.li
blog.self.li
Quite frankly, I know I'd be quite puzzled if a message popped up out of nowhere telling me "You might be logged out, please, back up your content and refresh the page!".
What do you mean by I /might/ be logged out? Am I logged out or not? And why would I be logged out? What does this have to do with anything anyway?
And what on earth am I supposed to do to "back up my content"? What does this even mean?
And what is this "refreshing the page" business all about?
To be honest, being a developer myself, I would actually figure out what you actually mean. But I can guarantee you that 99.9% of the people out there won't have the faintest clue of what you're talking about. They'll just do what they always do in this case: they'll click OK, or Cancel, or whatever they think is going to make the annoying message go away.
Look at a calender and note the year. Now realize that NSCA Mosaic was released in 1993. Eternal September was in 1993 as well. That is almost 20 years ago. Do you really think that 'refreshing the page' is beyond 99% of peoples knowledge?
That error message does need cleaning up but your target audience are most likely not fetuses, so don't treat them like they wouldn't be able to put their pants on in the morning if you didn't tell them how to in excruciating detail, despite doing it every day, when they visit your site.
Oh excuse me, a 'website' or a 'site' is a virtual location accessed through a 'web browser'. A 'web browser' is a program that is used to access 'web sites' over an interconnected series of networks called 'the Internet'. I know you said you're a developer and may be able to figure this out for yourself but as you said 99.9% of people wouldn't, I wasn't going to take that chance. Was it too advanced for you?
Also depending on the issue 'might be logged out' may be completely correct. Obviously something has occurred that is making part of the webapp believe something has gone wrong, but it probably still has "Welcome [username]" or "Logged In" at the top of the page. Reloading the page is really the only way to verify something really bad is going to happen.
One user complains about something that might have happened by his own doing and the OP starts implementing a feature, that not circumvents the end result (can't save the content) but notifies the user that the software is broken somehow.
Anyway, I'm genuinely interested in the following:
What are these "universe glitches", when one gets logged out by the browser? Session Cookie vanishes? Server restart invalidates some kind of access token?
To me, it sounds like they might be expiring the session due to inactivity, while the user is actively writing something.
EDIT: Typo
And the solution is the ping that he proposes. So if that was the problem, the ping is resetting the session cookie every 60 seconds and the problem should go away.
One thing I would add is a logging feature that tracks how many times this actually happens (is happening) so they have metrics to back up any decision in the future.
It happens a lot here where I work: our legacy ASP.NET WebForms use Sessions (because it used to be easier this way) and once in a while people complain that the app kicks them after some 20 minutes.
I've had a situation in the past where a session has regenerated - giving the impression of expiring - due to lots of AJAX calls over a period in time. Basically, you got X number of pageviews with the current session token before a new token was generated.
IIRC, the browser's session cookie wasn't getting updated due to the calls being via AJAX, and hence the user was logged out. It's been a long time since this happened though, so I may have a detail wrong.
On the front end, auto-save is done using an XHR call from JavaScript. If we detect a 302 response from the server, and the Location: header was set to a known login pattern, we'd inform the user of this, and allow them to log in in a new window/tab.
On login, the new window/tab redirects the user back to a page in our app. The page in our app does two things. 1. It calls window.opener.someCallback() 2. It calls window.close()
The callback function then makes a call to the server to fetch a new csrf token (you do use csrf tokens, don't you?) and then re-attempts the save.
This reduced user frustration significantly.
I do not know if this app is still in use.
My company had a problem with clients being logged out after 20 minutes. You would think this is enough time but some people would spend hours editing content without pressing save. We implemented 2 solutions. The first was an auto-save. This pinged the server and removed the primary cause of the issue. The second thing was a warning which triggered after 15 minutes of inactivity. If they pressed OK some data would get sent to the server and the timer would start again. We are not concerned about random "universe glitches"
I would have thought a better way would be to add a listener for form submissions. Check if user is logged in. If so - send data. Otherwise login form can pop up or data can be put into a session or something and reappear after the client logs back in.
This means the user doesn't need to know how to copy and paste.
To make this secure, make am-i-logged-in no-cache, don't store the ID in cookies/localStorage, encrypt/decrypt the relogin-as-user-X only on the server-side, and timestamp it with short TTL.
If you are already able to detect that the user has logged out unintentionally and just minutes prior to that you knew they were logged in, then you might as well just log them back in again. Of course, if the user logs out intentionally in one tab, then do not log them in automatically in the other tab. Simply stop returning any valid relogin-as-user-X IDs.
Why not save the content as a 'semi-anonymous' user, together with the user's session cookie and on the next login tell there's some ghost session lurking around and whether it should be kept?