Added notice for max number of active session. - #21
Conversation
|
Thanks @navidabdi @NotARobit @sun :) I will merge this to upcoming release v2.0. |
|
Sorry! This was actually meant as a PR against the feature branch in @NotARobit's fork, so that it would become part of the main PR #19 – we absolutely did not intend to replace that PR or ignore his excellent work! 👌 And I'm sure @navidabdi also meant to add a description explaining the intention here 😅 Sorry for the mess. 😬 But if this is okay for you, then we would leave it like that now. |
| unset( $sessions[ $oldest_token ] ); | ||
| update_user_meta( $user_id, 'session_tokens', $sessions ); | ||
|
|
||
| $this->add_notice_oldest_terminated = true; |
There was a problem hiding this comment.
Also note that the workaround with the class property probably is not required anymore.
The missing part was to set the session cookie at the end of the POST login request with WC()->session->set_customer_session_cookie( true ) before the redirect response is issued. This is normally only happening in the woocommerce_init event at the beginning of the request.
Without setting the cookie, the shutdown handler calls WC_Session_Handler::save_data(), which saves the notice for the session into the database, but the HTTP response does not actually contain a session cookie. Therefore, the message is never displayed to the user.
So we can probably significantly simplify the changes for adding the notice to just these lines without the class property and the separate hook:
https://github.com/Joel-James/loggedin/blob/c8dc03d18f683b388aed96e19a12f148b6fc5628/includes/class-loggedin.php#L262-L268
There was a problem hiding this comment.
@sun @joel-james - I tested the feature once more, and we didn't need the extra hook to wp_login and also setting the extra argument $add_notice_oldest_terminated, so I removed them.
…ature/warning-message-when-login-terminates-oldest-message
|
@joel-james Is there anything we can do to get this small addition over the finish line? 🙂 |
|
@sun Sure. I’ll include this in the next release. Sorry for the delay. |
No description provided.