Data not available on redirect
-
I have something like this inside one of my functions which is triggered by the init action:
$wp_session = WP_Session::get_instance(); ... $wp_session['form_response'] = array( 'yep' => 'hello', 'status' => 'success', 'msg' => 'Updated successfully.' ); wp_redirect(get_field('vendor_dashboard_page', 'option')); exit;
The $wp_session data is not accessible after the redirect using the following in a page template:
<?php $err = array(); $p = array(); $wp_session = WP_Session::get_instance(); if(isset($_POST['shop_update'])) { $p = $_POST; if(isset($wp_session['form_response'])) { if(isset($wp_session['form_response']['err'])) $err = $wp_session['form_response']['err']; if(isset($wp_session['form_response']['msg'])) $msg = $wp_session['form_response']['msg']; } }
Also.. do I need to unset $wp_session after it’s used? If so, what’s the best way to do that.
Thanks!
- The topic ‘Data not available on redirect’ is closed to new replies.