Categories
WordPress

[Login-with-AJAX issue solved] – Logout user when browser is closed

After installing a plugin “Login With AJAX”(version 3.0.4 or less), I faced a issue with wordpress logout. The issue was:

The user is kept logged-in even after the browser is closed !! The user needs to logout explicitly from the site.

In general, browser clears the cookies(Session Cookies) set by WordPress for the logged-in user when the browser is closed, but the way “login-with-ajax” submits the login-form data, it always set the “remember me” value to something(long time in future) which makes the cookie as persistent. So the cookie never expires and user is kept logged-in always evenif browser is closed.

Follow the steps below for a quick fix to the above problem:

  • – Read the section “Customizing the Widget” here http://wordpress.org/extend/plugins/login-with-ajax/other_notes/ so that we can change a cor plugin file.
  • – Open the file “login-with-ajax.source.js” inside the widget directory and copy the whole code inside it, then paste the code into the file “login-with-ajax.js” and save. We are doing this to have un-minified version of code, for ease of editing. 🙂
  • – Search the function “getPostData” and add the below lines after el = $(el);
  • – Code after changing, looks like below:
  • – Save and check. 🙂 Now, after browser close, it should be logging out the wordpress user