PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
on one page, however, the session variable doen't seem to register or stay persistent on other pages, after much trial and frustration, i decided to declare it in the previous page, guesse what, the variable is registered....!(By the way, session_start() has been added on all pages. This is not my first experience in this incident, anyboby ever came across the same thing? pls help..
<?php
check_valid_user();
$_SESSION['string'] = 'baby';
//the function
function check_valid_user();
// see if somebody is logged in under the same session, notify them if not
{
global $_SESSION;
if (isset($_SESSION['user']))
{
echo 'Logged in as '.$_SESSION['user'].'.';
echo '<br><br>';
}
else
{
// they are not logged in
do_html_heading('Problem:');
echo 'You are not logged in.<br><br>';
do_html_footer();
exit;
}
}
?>
de_php at amano7 dot org wrote:
if you use global with $_SESSION, it won't work.
The vars you put in $_SESSION won't be stored in the area where you use global with it.
So it's "it crashes if you do so" instead of "you don't have to" on that topic.