I've done lots of PHP programs but never any that required any kind of login system so I was wondering what's the most secure way to create one.

Would it be via the use of Sessions or Cookies or something else? How do you allow someone to verify their information and stay logged in until they log out? And how would you handle the log out?

Everytime I've tried to look this up, every site seems to have a completely different way to do it so I didn't know if there was ways that should be avoided or ways that should be used.

Thanks

Also, if anyone has a very very bare bones example that would be appreciated (but not necessary).