session cookie in AJAX request
-
Hi,
I’m currently developing a front-end plugin that uses AJAX quite extensively. I’ve developed back-end plugins before and never had any problems with AJAX there, but it is killing me in the front-end.
I use this code to trigger the AJAX action:
add_action('wp_ajax_search', array('WPPictureTagFrontend', 'handleAjax'));And call the action with this JQuery:
$.post(wnm_custom.url + "?action=save" , {'data': form.serializeFormJSON(), 'cookie': encodeURIComponent(document.cookie)} , function(data){...wnm_custom.url is the correct URL, passed on by the JS i18n.
But when I try to do anything that requires the session cookie, WP doesn’t recognize the cookie. For instance when I do this:
if (is_user_logged_in()) return true; else return false;The statement returns false.
How do I allow JQuery to pass the session cookie in an AJAX request? I’ve ran out of ideas and frankly, I’ve haven’t seen somebody give a straightforward answer to this problem.
The topic ‘session cookie in AJAX request’ is closed to new replies.