Don't know if I should post this here or in the jquery forum.
But here is the deal.
My index.php has the following ....
<?php
session_start( [ 'cookie_lifetime' => 86400, ]);
//session_start();
//$SID = session_id();
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
include_once( '../gallerysoftconfig.php');
include_once( 'functions.php');
include_once( '../iconfig.php');
include_once( 'indexPreChecks.php');
include_once( 'sessionChecks.php');
include_once( 'screenDetect.php');
//print_r($_SESSION);
//$xyz = $_SESSION['gs_session_screen_width'];
//echo "Width: $xyz <br>";
As you can see lots commented out for testing
Then the issue is in screenDetect.php
And here is screenDetect.php
<?php
if( isset($_REQUEST['sw'] ) ) {
$screenWidth = $_REQUEST['sw'];
$_SESSION['gs_session_screen_width'] = $screenWidth;
//$s = $_SESSION['gs_session_screen_width'];
//echo "New session processed: $s";
return;
}
if(isset($_SESSION['gs_session_screen_width']) ) {
$screenWidth = $_SESSION['gs_session_screen_width'];
//echo "Session processed: $screenWidth";
return;
}
if(! isset($_SESSION['gs_session_screen_width']) ) {
echo '
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script type="text/javascript">
var screenWidth = screen.width;
$.ajax({
type: "POST",
url: "/screenDetect.php",
data: {sw: screenWidth},
success: function() {
}
});
</script>
';
}
?>
There are some comments there that I use for validation But the story is, that the ajax call is simply getting the device screen size and calling it self with a POST. That works just fine
The if( isse($_REQUEST['sw']) ) does get executed and sets the session. I have validated this by assigning the session to a variable and it does print it. I even do a print_r($_SESSION) and I see it. However, when I pickup the code in index.php, the session that was set there is no longer visible. Its like it never existed.
I have tried the session_start() at the begining of screenDetect but no luck.
Any idea what is going on ???
Thanks
JT