From 261c3320879f20bede877ab53f9e4142e48c8a56 Mon Sep 17 00:00:00 2001 From: Thomas Seifert Date: Fri, 8 Jul 2011 10:54:49 +0200 Subject: [PATCH] first part of "Make Ajax calls without enabled cookies work". Server-side work is done with this commit. Now only the JS-part in the phorum ajax lib is missing (related to #816) --- ajax.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ajax.php b/ajax.php index 2ca364384..00cc5b715 100644 --- a/ajax.php +++ b/ajax.php @@ -91,6 +91,19 @@ $ajax_call = basename($PHORUM['ajax_args']['call']); +// try to get some session-id if there isn't already a user loaded through +// the regular ways +if(empty($PHORUM['user']['user_id'])) { + // check if we got a session-id in the ajax args and if we got one + // try to load a user with that data + $ajax_session_id = phorum_ajax_getarg(PHORUM_SESSION_LONG_TERM,'string',0); + if(!empty($ajax_session_id)) { + $PHORUM['use_cookies']=PHORUM_USE_COOKIES; + $PHORUM['args'][PHORUM_SESSION_LONG_TERM]=$ajax_session_id; + phorum_api_user_session_restore(PHORUM_FORUM_SESSION); + } +} + /** * [hook] * ajax_ @@ -198,8 +211,6 @@ function phorum_ajax_error($message) */ function phorum_ajax_return($data) { - global $PHORUM; - header("Content-Type: text/plain; charset=UTF-8"); print phorum_api_json_encode($data); exit(0);