Session Security?

Viewed 270

Is it secure to use

If ($_SESSION['authenticated'] == true) {
    /////Show secure page
}

Can someone just go and change where the session variable is stored to make their $_SESSION['autheticated'] = to true?

Same thing with a user having $_SESSION['id'] = to their index id. How would I be able to make this securer? Could someone just go and change the id value and impersonate another user?

Would the below method be the right way to make something securer?

$_SESSION['random_check'] = (random number) 

and also store this in a column in my database and each time I would

If ($_SESSION['authenticated'] == true &&  $_SESSION['random_check'] == random_number ) {
/////Then show secure page
}

Thanks,

2 Answers
Related