开发者

Condition for retrieving Cookie through AJAX calls

I'm new to the cookie. But I think I might have done some wrong with my PHP code. During login process I have a verify login script that verifies the user. And if the user passes it the script will automatically set a cookie, set开发者_C百科cookie("userid", $row["profileId"], time() + 24*3600*14); and the script also redirects the user to the main page with header("Location: ../../index.php"); As I'm looking on the network tab in Google Chrome's developer tools, I can see the cookie just for the verify script, both request cookie and response cookie. But why can't see this on all other AJAX request? I can't retrieve the cookies at all, what have I done wrong? I know I have made some common pitfall

The only Cookie I can retrieve is the session cookie. I need the retrieve the cookie using $_COOKIE in php. I'm using localhost as the domain


Cookies are fully automatic. You don't need to grab them in js to send them. The ajax call with automatically send them in the request, you can even set more with the response. But you must be on the same domain for any of this to work. Cross domain cookies are disabled for security.


cookies are client side, http://plugins.jquery.com/project/Cookie

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜