he Kurt, Given the question you ask is very much a beginners question I assume that you are not working for LCMG as a programmer? nothing wrong with that, per se ... BUT working for a large IT company you are expected to realise that the whole internet community is not just there to answer you your personal questions and fix your problems. so please address your questions to an appropriate forum [php-generals mailing list in this case] - i.e. not to some random stranger who email address you plucked from the internet because you decided you want them to help you. [that means replying to the list address and not me if you want to response to my post] (I'm pretty sure that LCMG wouldn't answer my IT questions if I just started 'cold-emailing' their techsupport - rather I first need a 200euro/hour support contract before anyone will help me; <-- not to far from the truth?) Vandevelde, Kurt wrote:
Hello, I saw in the PHP newsgroup that you were having problems with the PHP Session. I just started using PHP a few days ago and I have the following problem :
unless you found a 3 year old post I suspect you saw me (trying to) help someone else who was having Session related problems.
It seems that $_SESSION is not recognized. I read that I must use session_start(); before I can save data. Is there anything else that has to be done? I used the following code. Do you know what my be wrong?
seems? wht does is 'seem' - state the problem you actually experience, verbalizing a gut instinct that something 'seems' to be 'not recognized' is rather vAgue and therefore pointless. likely you are not yet familiar with the way php autocasts variables. e.g. look what happens here: echo ""; // echo an empty string echo null; // echo a 'null' echo false; // echo a boolean false as opposed to: var_dump($a = ""); var_dump($b = null); var_dump($c = false);
<?php session_start();
echo '<pre>'; var_dump(isset($_SESSION['LoggedIn'])); var_dump($_SESSION);
if (!isset($_SESSION['LoggedIn'])) { $_SESSION['LoggedIn'] = false; $UserLoggedIn = false; } else { $UserLoggedIn = $_SESSION['LoggedIn']; } echo $_SESSION['LoggedIn']; echo '.'; echo $UserLoggedIn; ?>
learn to debug your code, start with the these functions: print_r(); var_dump(); they will help you to figure out what your variable contain while your script runs and thereby (usually) figure out why your script is not doing what you expect. unless you are using a an old version of PHP $_SESSION will exist in your script after you call session_start().
Thanks, Kurt Vandevelde Belgium.
<removed legalese mindrot> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php