One of the basic files in a particular package is a file that checks for valid session data, and if none exists, redirects the user to the login page with an error, using header("Location:" . $var);.
This file is included in pretty much all files within the package, as it has other elements which are required (such as including either files depending on certain factors). However, a fair few of the files in which it contains are requested via AJAX.
Will the header() redirect still work and have the user redirected even though the request is made via AJAX, or will the page itself simply redirect, causing an initial AJAX request to say page1.php to turn into an AJAX request to page2.php?
Any answers would be very much appreciated!
The redirect will not bubble back up – only the AJAX request will be redirected. You could contrarily return the location of the redirect as the body of the AJAX content and use that in the success function as a
location.href = "<URL from AJAX call>";call or just return a particular error response and redirect accordingly.