Skip to content

Commit b4cef93

Browse files
Andrew Bakerclaude
andcommitted
fix: session cookie — move force_remember hook from login_form_login to login_init
login_form_login is a form display hook that never fires on a successful login POST (WordPress redirects before re-rendering). Moving to login_init (priority 5) ensures $_POST['rememberme'] is set before wp_signon() reads the credentials, so the auth cookie is written with an explicit expiry instead of expire=0 (session cookie cleared by browser on app close/swipe-up). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1c0c6db commit b4cef93

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

cs-code-block.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: CloudScale DevTools
44
* Plugin URI: https://andrewbaker.ninja
55
* Description: Developer toolkit with syntax-highlighted code blocks, SQL query tool, code migrator, site monitor, and login security (passkeys, TOTP, email 2FA, hide login URL).
6-
* Version: 1.8.88
6+
* Version: 1.8.90
77
* Author: Andrew Baker
88
* Author URI: https://andrewbaker.ninja
99
* License: GPL-2.0-or-later
@@ -38,7 +38,7 @@
3838
*/
3939
class CloudScale_DevTools {
4040

41-
const VERSION = '1.8.88';
41+
const VERSION = '1.8.90';
4242
const HLJS_VERSION = '11.11.1';
4343
const HLJS_CDN = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/';
4444
const TOOLS_SLUG = 'cloudscale-devtools';
@@ -311,9 +311,11 @@ public static function init() {
311311
add_filter( 'site_url', [ __CLASS__, 'login_custom_site_url' ], 10, 4 );
312312

313313
// Brute-force protection — check before authentication (priority 1, before password check).
314-
add_filter( 'authenticate', [ __CLASS__, 'login_brute_force_check' ], 1, 3 );
314+
add_filter( 'authenticate', [ __CLASS__, 'login_brute_force_check' ], 1, 3 );
315315
// Force persistent cookie when a custom session duration is configured.
316-
add_action( 'login_form_login', [ __CLASS__, 'login_force_remember' ] );
316+
// Must be login_init (fires before the POST is processed) not login_form_login
317+
// (which is a display hook that never fires on a successful login POST).
318+
add_action( 'login_init', [ __CLASS__, 'login_force_remember' ], 5 );
317319
// Security monitor — always track failed logins regardless of monitor toggle.
318320
add_action( 'wp_login_failed', [ __CLASS__, 'perf_track_failed_login' ] );
319321

@@ -4214,12 +4216,18 @@ public static function login_session_expiration( int $expiration, int $user_id,
42144216
}
42154217

42164218
/**
4217-
* When a custom session duration is configured, forces "remember me" on the
4218-
* standard WordPress login form so the auth cookie is written as a persistent
4219-
* cookie (non-zero expiry) rather than a session cookie that browsers clear
4220-
* when closed.
4219+
* When a custom session duration is configured, forces "remember me" so the
4220+
* auth cookie is written as a persistent cookie (non-zero browser expiry)
4221+
* rather than a session cookie that browsers clear when closed/swiped away.
42214222
*
4222-
* @since 1.9.5
4223+
* Hooked to `login_init` (priority 5) — fires before WordPress reads
4224+
* $_POST['rememberme'] when processing the login form POST, so wp_signon()
4225+
* receives remember=true and wp_set_auth_cookie() sets an explicit expiry.
4226+
*
4227+
* Note: login_form_login is a DISPLAY hook (fires when rendering the form)
4228+
* and never fires on a successful login POST — do NOT use that hook here.
4229+
*
4230+
* @since 1.8.88
42234231
* @return void
42244232
*/
42254233
public static function login_force_remember(): void {

readme.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: code block, syntax highlighting, gutenberg block, dark mode, highlight.js
44
Requires at least: 6.0
55
Tested up to: 6.7
66
Requires PHP: 7.4
7-
Stable tag: 1.8.88
7+
Stable tag: 1.8.90
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -79,7 +79,10 @@ Yes. Press Enter to run the query. Use Shift+Enter to insert a newline. Ctrl+Ent
7979

8080
== Changelog ==
8181

82-
= 1.8.88 =
82+
= 1.8.90 =
83+
* Fixed: session cookie hook was wrong — login_form_login is a display hook that never fires on a successful login POST; moved to login_init so the persistent-cookie flag is set before WordPress processes credentials
84+
85+
= 1.8.89 =
8386
* Added: Brute-force protection — configurable per-account lockout after N failed login attempts (default 5 attempts, 5-minute lock), with admin UI to adjust both thresholds
8487
* Fixed: Session persistence — login sessions now survive browser close when a custom session duration is set (auth cookie was a session cookie; now writes a persistent cookie)
8588
* Added: Thumbnails tab — Social Preview Diagnostics with URL checker (9-point OG/image diagnostic), recent posts auto-scan, Cloudflare WAF setup guide + crawler UA tester + cache purge, and Media Library auditor with one-click recompress for oversized images

0 commit comments

Comments
 (0)