cyclone200
cyclone200

Reputation: 387

Check whether a user is logged in

I've just figured out that my login system was absolutely not secured.

So I thought about something :

setcookie ("pseudo", $_POST['pseudo'], time() + 36000);
if (isset($_COOKIE['pseudo']))

But what I don't understand is that anyone can create a cookie named pseudo... So does that mean that I should store the password in a cookie and check on each "member" page the database ?

Upvotes: 0

Views: 53

Answers (1)

kmas
kmas

Reputation: 6439

You have to use sessions and their variables, they are stored on the server, thus the user cannot change their values.

Read this : http://php.net/manual/en/intro.session.php

And this : http://php.net/manual/en/session.examples.basic.php

If your connection is okay, create a session (do any stuff you want to do when a user is connected).

Upvotes: 2

Related Questions