Reputation: 21
Which are the common scenarios where both can not use together ?
Upvotes: 2
Views: 319
Reputation: 157872
There is not much difference between AJAX requests and direct ones. Especially from the server-side point of view.
Your PHP script process a request and send out some data. It is really doesn't matter, who did that request - a browser itself or some JS object, running in the browser.
Frankly, AJAX just has nothing to do with sessions - it's PHP's realm
Upvotes: 5
Reputation: 1726
Be sure that all you script use the same domain, you can ensure that by positioning it before calling session_start :
session_set_cookie_params(0, "/", example.tld)
Upvotes: 0
Reputation: 70001
If the call is through the same domain (example.com/index.php calls example.com/ajax.php) then it should be enough to call session_start()
in both places and the user's session should be used.
Upvotes: 0