Reputation: 2696
I am setting cookies using jquery+jquery cookie.
jQuery.cookie('status', 'active', {expires: 1, path: '/'});
Now how can I set this cookie using AJAX? regarless of jquery cookie, how would you set a cookie using ajax in jquery, anyone has any idea.
Links to original question (PHP & JQuery passing variables)
update
So I am making the AJAX request like so in my jquery code
$.ajax({
url: "script.php",
type: "GET",
data: { status: active}
});
And in my php I am processing it like;
if($_GET['status']!='')
{
setcookie("status", $_GET['status'], time()+3600);
}
but nothing is happening, no cookie is being set. can anyone see the problem,
Upvotes: 0
Views: 2898
Reputation: 39248
You can set the cookies on the server the same you would for a normal page request. Just look into your server side language of choice's way of setting cookies. Ajax requests are nothing more than normal http requests. When the response gets back to the server the cookies will be set set by the browser.
PHP: http://www.w3schools.com/php/php_cookies.asp
Upvotes: 1