Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] Login loop caused by POST grace period on expired auth cookie

Simple Membership Plugin › Forums › Simple Membership Plugin › Login loop caused by POST grace period on expired auth cookie

  • This topic has 3 replies, 2 voices, and was last updated 2 weeks, 3 days ago by admin.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 13, 2026 at 4:33 am #32369
    freetiermorioka555
    Participant

    Hello,

    Environment: WordPress 6.9.10. Reproduced with Simple Membership 4.4.3 and with the current version.

    We found a reproducible login loop in Simple Membership.

    Steps to reproduce
    1. Log in with “Remember me” checked.
    2. Wait until the internal cookie expiration (14 days) has passed. The browser still holds the cookie for another 12 hours, because set_cookie() sets the browser expiry to expiration + 43200.
    3. Open any page. The member is shown as logged out (validate() reports “Session Expired”).
    4. Submit the login form within one hour of the expiration.

    Expected: the member is authenticated, a new auth cookie is issued, and the after-login redirect runs.
    Actual: the login page is rendered as the “logged in” account page, no redirect happens, and the next page view shows the member as logged out again. The member can repeat this for up to one hour.

    Cause (class.swpm-auth.php)
    – validate() adds a one-hour grace period for POST and AJAX requests ($expired += HOUR_IN_SECONDS).
    – init() / auth_init() only calls authenticate() when validate() returns false.
    – So when the login form is POSTed with an expired cookie inside the grace period, validate() returns true, authenticate() never runs, and no new cookie is set. The old cookie keeps expiring on every GET.

    A related issue: logout() returns early when $this->isLoggedIn is false, so a member in this state cannot clear the expired cookie by logging out.

    Suggested fix
    – In init() / auth_init(), when the login form was submitted (POST with swpm_user_name and swpm_password), skip validate() and always call authenticate().
    – In logout(), clear the auth cookies even when the member is not considered logged in.

    Thank you.

    October 13, 2026 at 6:06 am #32373
    admin
    Keymaster

    Hi, Thank you for the detailed report and the clear analysis. It made this easy to track down.

    We’ve confirmed the issue. If the login form is submitted within the one-hour POST grace period after the login cookie has expired, the old cookie is still accepted for that request. As a result, the login isn’t processed and no new cookie is set, which causes the loop you described. You were also right that the logout request returns early in that state and leaves the stale cookie in place.

    We’ve applied a fix for both:

    A login form submission is now always processed, even if an expired cookie is still within the grace period. This creates a fresh login session.

    The logout request now clears any leftover auth cookies, even when the login session is no longer valid.
    The fix is going through testing now and will be in the next plugin update, which should be out in the next few days. Until then, a member who runs into this can clear the site’s cookies in their browser and log in again.

    October 16, 2026 at 6:07 am #32380
    freetiermorioka555
    Participant

    Thanks very much for looking into this so quickly, and for the clear explanation.

    Your description matches exactly what we were seeing, so the fix sounds right to us.
    It is also good to know the logout path is covered — that was the part we were least
    sure about.

    In the meantime we will pass the cookie-clearing workaround on to our support team.
    Once the new version is out we will update and verify on our side, and we will report
    back if we see anything unexpected.

    Thanks again for the quick turnaround.

    November 3, 2026 at 6:11 am #32454
    admin
    Keymaster

    We have released Simple Membership version 4.8.7, which includes the fix.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy