0

In php, I'm wondering how the setcookie() function can modify the client side cookie when I use a separated way between client and server to communicate(like only by ajax call and return json data). In this case, does a call to this function in server side automatically send back a new http header to client? otherwise how would the function call modify cookie data at client side?

zonyang
  • 828
  • 3
  • 10
  • 24
  • Possible duplicate of [php setcookie not working with ajax call](http://stackoverflow.com/questions/5636506/php-setcookie-not-working-with-ajax-call) – Ralph Melhem Apr 27 '16 at 06:16

1 Answers1

0

setcookie() function works because when your php code executing on server side it can save the values to the cookie, you only need ajax here if you wish to modify that cookie without refreshing the page. And after the page reloads, again the same cycle will happens and it can modify the cookie.

Sarvagna Mehta
  • 334
  • 3
  • 16