ZeroSuf3r
ZeroSuf3r

Reputation: 2001

user authentications via session or cookies?

This moment if user enter's correct username and password i just simply creating session:

$_SESSION['userid'] = $user_data[0]->id;
$_SESSION['username'] = $user_data[0]->username);
$_SESSION['loggedin'] = true;

After that, with $_SESSION['loggedin'] i can check if user can view part of website or not.

Is this method 'good/safe' ?

Upvotes: 0

Views: 192

Answers (2)

itachi
itachi

Reputation: 6393

If you are using any framework, then most framework comes with authentication library.

And for other purposes you can use phpseclib (a security library....). Its still in beta stage. I have tried it. Sounds promising.

Upvotes: 0

Kiwimoisi
Kiwimoisi

Reputation: 4182

Have a look at this great answer from Joel Coehoorn on this page . Most of your questions are answered in this post.

Web authentication state - Session vs Cookie vs?

I hope this will help.

Cheers

Upvotes: 1

Related Questions