Page 1 of 1

logging in on an account on a webpage - SQL and php

Posted: Thu Jan 14, 2010 5:56 pm
by jimiwa
I'm working on a website where I'm designing a interactive
website kind of social-networking style where users
create an account, can post discussions on boards,
and create their own mini-websites within the main website,
and having other various interactive stuff.

I'm just starting on the basics as I haven't worked much with php
before even though I've had quite a few years of non-professional
programming practice.

I have it so that the user types in name, username, and password
and then the user is sent an email to validate the account. I
have it so that a validation email is sent and the user then validates
the account, where the sql database "validated" variable is set
to true.

Haven't gotten past this point, but I'm wondering, how do I have
a user log in, and exactly how does my website know that the user
is logged in when he or she moves from page to page on the website,
and how does my website know when that person is logged out?

Re: logging in on an account on a webpage - SQL and php

Posted: Thu Jan 14, 2010 6:01 pm
by AbraCadaver
You log them in by checking their username and password in the database. You would then use sessions that persist variables across pages. You could set a session var with their userid and then check to see if that is set on other pages to see if they are logged in or not. To log them out, you destroy the session and unset the session vars.