• Resolved RLoveday

    (@rloveday)


    There seems to be no automatic logging out of my password protected page per the Protected Posts Logout Button plugin, other than if I refresh the page.

    The setting is currently at 3 minutes. Even if I visit another page on my website after 3 minutes, I’ll press the back button and I’ll still be logged in.

    Is there any setting other than the cookie expiring time where automatic log out can be enabled?

    Any information and guidance would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Nate Reist

    (@natereist)

    Hey @rloveday,

    Sorry you are experiencing some issues with the cookie time. Unfortunately that is expected behavior in the instance you have explained. Hitting the back button doesn’t re-render the page with PHP ( which is where the cookie check happens ), but just steps back a step in the browser history, to a point where you were already logged in, it doesn’t check at that point, that is why a page refresh is required to log you out of password protected posts and pages.

    In order to get the page to automatically log you out without a page refresh, would need to have a process that checked on the server whether the password cookie had expired, then if it had, that process would need to refresh the page for you automatically. This could be done with a Javascript using the WP heartbeat api, or an interval function using WP AJAX. In either process you would need to have an action listening on the server ( PHP ) to return to you whether or not it had expired.

    Thread Starter RLoveday

    (@rloveday)

    Hi Nate,

    Thanks for getting back to me, I really appreciate it. Forgive me, but I’m not very technically minded, can you dumb down the second paragraph of your answer for me?

    Are the WP Heartbeat API and the WP AJAX plugins or tools? And what is an action listening on the server?

    If you could please clear this up for me, I would really appreciate it.

    Thank you.

    Plugin Author Nate Reist

    (@natereist)

    Those are internal WordPress programming tools.

    The heartbeat API is a tool that can check at a regular interval with the server and get data over a XMLHttpRequest using JavaScript. It runs like a clock tick,
    for example: every X seconds, check for new posts..
    The AJAX API is similar, Javascript makes a XMLHttpRequest to the server but you usually would do this when some action happens from a user, for example: when a user completes form submission or clicks a button.

    Both of those happen in the user’s browser (chrome, safari, firefox etc.) on their computer and then talk to your web host (server) which must be listening for that XMLHttpRequest. The server can then process that request, and return a response that can be used to accomplish something in your user’s browser without out them reloading the page or in your case, it could force the browser to reload if the cookie had expired.

    That would require custom code to implement, I don’t know of any plugins available that would allow you to do this without writing some custom code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cookie expiring time not working properly’ is closed to new replies.