set cookie won’t work
-
I’m using Ninja forms and am trying to make a plugin where they have to log into an account so they can register for events. I have the page with a form that asks for their user name and password. When they submit the form, I check their creds and if everything is okay, they get redirected to the same page where I have code that is hooked into the init that is suppose to set some cookies and then redirects. It is redirecting but I can’t get the cookies to set. I’ve been at this for about four hours now and can’t figure out what I’m doing wrong. Any help is appreciated!
add_shortcode('bbr_account', 'bbr_account_func'); function bbr_account_func() { return var_export($_COOKIE['account_id'],true); } if(!is_admin()) { Global $wp; $dslug = $_SERVER['REQUEST_URI']; if($dslug=='/dpi-sign-in/') { add_action('init', 'bbr_login'); } } function bbr_login() { Global $wpdb; $uip = $_SERVER['REMOTE_ADDR']; $login_info = $wpdb->get_row('SELECT * FROM '.$wpdb->prefix.'bbr_login WHERE ip LIKE "'.$uip.'"', ARRAY_A); if(!is_null($login_info)) { $user_info = $wpdb->get_row('SELECT * FROM '.$wpdb->prefix.'bbr_usrs WHERE id = '.$login_info['id'], ARRAY_A); $wpdb->delete($wpdb->prefix.'bbr_login',array('id'=>$login_info['id'])); setcookie('account_id',$user_info['id'],time()+3600,'/','www.register.dynamicpathwaysinc.com'); header('refresh: 4; url=/account'); }
When it gets redirected, I get Notice: Undefined index: account_id in /home/dpiadmim/register.dynamicpathwaysinc.com/wp-content/plugins/ninja-forms-dpi-registration-system/ninja-forms-dpi-registration-system.php on line 17 NULL
- The topic ‘set cookie won’t work’ is closed to new replies.