Can somebody enlighten me as to the best way (or, if it's even possible) to access session data in a php/js file that is injected into the DOM?
Illustrative example, to be more clear:
index.php:
<?php
session_start();
$_SESSION['logged_in'] = true;
?>
<script type="text/javascript" src="http://www.domain.com/include.php"></script>
include.php:
<?php
session_start();
$logged_in = $_SESSION['logged_in'];
?>
alert("<?php echo $logged_in; ?>");
The include.php script is one that, ideally, any client could drop into their header, not that that necessarily matters. I do have the ability to pass parameters in the script URL (i.e. http://www.domain.com/include.php?s=213409239323939) so I've thought about passing the session ID that way, but I'm unsure if there are inherent security risks in exposing the session ID. Any advice or thoughts are welcome.
** EDIT - I should make clear that the script file (include.php) is a different domain name
loggedinvariable in the original document might already be enough