View Full Version : security.php

04-02-2007, 12:38 PM
there is something wrong with this code
if (! isset($_SESSION['id'])) {

header("location: login.php");



this wnt let me login but when i remove it i am able to login. what have i done wrong?

04-02-2007, 12:43 PM
ok i found a solution,
when you use session_start before this code it works, however if you use session start after it doesnt.

In the video tutorial it stopped before you ran it and tested it.

This is all good and well but why is this happening, why does it have to be before other than after. I kind of have an idea but it would be better if you would explain it.

04-02-2007, 04:01 PM
another gold star

yes i admit there is a bug

i realised what i had done a while ago but waited for someone pointing this out.

well done for finding this and putting it right.

always initialise sessions by using the SESSION_START(); at the begining of a script preferably at the top.

You after my job Predator?

04-02-2007, 04:04 PM
lol of course not i am no expert at this, im just a fast learner. :D and i just like helping around to return the favour.