isset doesn't work...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I try to check if a session variable is set. If it is not set it is given a
0 for default and forces the user to go to a login screen. Correct login
results in the session variable to go to 1 and let the user see the rest of
the page. Unfortunatly $_SESSION['ingelogd'] is never set and thus always
set to 1. I can't see what is wrong with the code.

 $_SESSION['ingelogd'] = 0;

if ($_SESSION['ingelogd'] == 0)
 $_gebruiker = getPost('gebruiker');
 $_paswoord = getPost('paswoord');

 if ($_gebruiker == 'ward' && $_paswoord == 'face' )
  $_SESSION['ingelogd'] = 1;
  header('Location: thispage.php');
 <form action="beheer.php" method="post">
 gebruiker: <input name="gebruiker"><br>
 paswoord:  <input name="paswoord"><br>
 <input type="submit" value="submit >>">
 </form> <?
 printf('SESSION: '.$_SESSION['ingelogd']) ;
// rest of page

Re: isset doesn't work...

Stijn Goris wrote:
Quoted text here. Click to load it

This looks like it should work ...

Did you put


at (or near) the top of *all* your scripts that need the session

You may want to turn on error_reporting too. Insert

    ini_set('display_errors', '1');

right before the session_start() line

Does the $_SESSION[] work at all?
Do you have your php.ini correctly configured?

Try this, and keep reloading (refreshing) the page

if (!isset($_SESSION['count'])) $_SESSION['count'] = 0;

echo 'count = ', $_SESSION['count'], '<br><br><br>';
echo 'Reload (Refresh) this page!';

USENET would be a better place if everybody read:   | to email me: use |   | my name in "To:" |     | header, textonly |                    | no attachments.  |

Re: isset doesn't work...

Quoted text here. Click to load it

The session_start() did the job. Thanks

Site Timeline