Session variables only works with exit;
-
I have a weird problem and it only happens in this specific function.
I usually use return; instead of exit; and it all works fine, but here the SESSION variables are just not working, unless I use exit; instead.function check_reset_link() { if ( is_page( 'reset-password' ) ) { $user = check_password_reset_key($_REQUEST['key'], $_REQUEST['login']); if( is_wp_error ($user ) ) { $lost_password_url = network_site_url( '/lostpassword' ); $_SESSION["errors"]["send-reset-link-error"] = "Reset link is invalid, you may request another one here."; wp_safe_redirect( $lost_password_url ); exit; return wp_safe_redirect( $lost_password_url ); // won't work } } } add_action( 'template_redirect', 'check_reset_link' );
When I process forms I just use return; and it all works great. Should I change everything to exit: instead?
By the way, I’m not sure when to use redirect VS. safe_redirect
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Session variables only works with exit;’ is closed to new replies.