I have a session created which is null when called from an ajax call on Safari.
header.php
session_start();
$_SESSION['test'] = 'this is my session';
mypage.php
session_start();
echo $_SESSION['test']; <-- NOT WORKING ON SAFARI
Thanks
It must be on every page you intend to use. The variables contained in the session—such as username and favorite color—are set with $_SESSION, a global variable. In this example, the session_start function is positioned after a non-printing comment but before any HTML.
You CAN use PHP sessions without cookies, as long as the browser identity is obtained somehow and yields a unique value (and this value is passed to the PHP session layer): session ID in GET (which is the "standard" PHP way if cookies are not allowed, and the "other" way you described).
session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie. When session_start() is called or when a session auto starts, PHP will call the open and read session save handlers.
Does it work in other browsers? Does it work in Safari without AJAX? Is this script being loaded from the same domain the original page is on?
Safari apparently has a more conservative cookie policy than other browsers. If everything on the PHP-side works, and other browsers work, I would think that Safari is not sending the session cookie back to the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With