Re: Trying to understand sessions and using them to authenticate...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, August 24, 2007 11:03 am, Jason Pruim wrote:
> Hi Everyone,
>
> I'm attempting to figure out the proper way to use sessions to log
> someone into my system. The idea being, if they arn't logged in all
> they can see is the login form, and if they are logged in, they and
> have access to a database of addresses.
>
> I think I understand how to start sessions, and store variables such
> as some sort of login identifier to say they have access to the
> database, what I'm running into  and have been googling about all
> morning so far, is how would I get the system to say they are logged
> in? Is it as simple as:
>
> $sql = "SELECT loginid FROM table where username="$username" and
> password="$password";
>
> and then setting session_register("loginid")
>
> and then checking to see if the variable exists? Or am I missing like
> huge chunks of info?

No, that's pretty much it.

Except you should get with the times and use:
$_SESSION['loginid'] = $loginid;
and then:
isset($_SESSION['loginid']);


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux