Ive had a user complain they were logged out while they were writing content. The documentation below talks about this issue, but I dont understand the conclusion. In the example below would the user be logged out and lose the content they were creating? Does comment creation work the same way as node creation?

Timeout value in seconds.

The is the "inactivity" timeout value. It's important to note that the server's only way of knowing about activity is when a browser requests a page from it. If the user is happily sitting there, say typing an enormous blog entry, then there's no way for the server to know the actual user is very busy until he/she submits the page. The server checks for any submissions (input) by the user. If there is content being added, the timeout is effectivly cancelled and a new session starts.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joekers’s picture

I had this problem, a user was logged out while writing feedback for the site.

In JS you can refresh the timeout whenever there is activity on the page, for example a form element is focused on or the user is typing.

jdln’s picture

So does the module do this automatically? I think that it certainly should if it currently doesn't.

joekers’s picture

No unfortunately it doesn’t do this already but it would be nice to have this in a future release

jdln’s picture

Category: support » feature

The timer for Automated Logout should reset when the user moves the mouse or presses a keyboard.

jdln’s picture

Title: Logged out when creating content / comment? » Reset countdown when a user types so content being created isnt lost

This really would be a massive UX improvement for this module. I think any key press or mouse click or scroll should rest the timer as this means the user is still active on a page.

johnennew’s picture

Version: 7.x-4.0 » 7.x-4.x-dev

If the user is typing they should get a popup alert before they are logged out. The latest updates to the 7.x-4.x branch ensure that they are not logged out in the case that they have two (or more) tabs open to the site and one times the user out whilst they are working in another.

Problem with resetting the timeout on user event is that the ajax call has to go back to the server to reset the timeout which could cause a lot of traffic.

A (possibly) better solution might be to use the newly introduced hook_autologout_refresh_only to specify a list of URLs which users cannot be logged out of when they are on it. This is a more flexible addition to the existing 'enforce logout on admin pages' option which, when not ticked, prevents logout when on any URL starting 'admin/'

johnennew’s picture

Status: Active » Needs review
FileSize
4.81 KB

Hi all,

I've thought about this some more and I think it will be possible to prevent autologout when a user is timing without generating large additional amounts of ajax traffic. The attached patch to the 7.x-4.x development branch sets a flag when a form is updated. When the logout popup is due to appear, this flag is checked and if set then the user must have been using the form. The flag is cleared, the last access time is updated on the server and the logout timer is reset.

Would be great if someone could test this and let me know if it's ok. I am going to be using it on one of my sites and will commit this if it's looking good.

You will need the latest 7.x-4.x dev branch code before applying this patch, it won't apply direct to 7.x-4.0

Kind regards,

John

johnennew’s picture

Slightly cleaner patch attached.

rooby’s picture

From a quick look at the patch it seems like a good idea.

Why is the CKEditor part necessary?

Does ckeditor catch the keyups and then update the underlying field in a way that keyup doesn't fire on the underlying field?

If so that's a bit annoying.

Does that mean this will possibly need additional handing for other text editors, like tinymce?

rooby’s picture

I feel we really shouldn't have to handle individual text editors here. It should be up to the module that provides the editor to integrate with the formUpdated behavior.

Related issues:
#1895278: WYSIWYG editor should allow Drupal to trigger 'formUpdated' event
#1993324: WYSIWYG editor should allow Drupal to trigger 'formUpdated' event

Since I only just openend the WYSIWYG module issue it is likely it won't be in a stable release for a while so I guess this workaround will still be needed for the immediate future.

johnennew’s picture

Version: 7.x-4.x-dev » 6.x-4.x-dev
Status: Needs review » Needs work

I'm going to leave this in for now - committing to 7.x-4.x and setting issue to 6.x-4.x for the backport.

johnennew’s picture

Status: Needs work » Needs review
FileSize
4.07 KB

Backport for 6.x-4.x branch attached.

johnennew’s picture

Status: Needs review » Fixed

Tests passed - committing to development branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 7f5e099 on 7.x-4.x, 8.x-1.x by ceng:
    Issue #1914156 by ceng: Reset countdown when a user types so content...