Page 1 of 1

Simple login with sessions tutorial

Posted: Tue Feb 04, 2003 7:02 pm
by nigma
I have found like 6 of them but they all contain stuff that is out of my league, I am looking for a tutorial that is just a simple login and logout tutorial while using sessions. I have MySQL setup so if you know of a tutorial that requires MySQL that is kool. All members of my site will be added by me, so no signup page is required. Thanks for all help and advice provided.

Posted: Tue Feb 04, 2003 8:00 pm
by volka
the link PHP Tutorials on top of this page takes you e.g. to http://www.phpcomplete.com/tutorials.ph ... adTutorial ;)

Posted: Wed Feb 05, 2003 5:20 pm
by oldtimer
I was in the same boat when I first started PHP like you. Nothing made sense. I have a little article that may help you.

http://www.coastgames.com/articles.php?articles=12

This is a very basic session that uses a table called users. You will see 3 variables that I passed. Their login name, username(the one they are known by) and their email address. This should give you the basic if you need them. Making a DB is pretty simple for it as well.

This Tutorial/article gives you how to setup the session and then you just have session_start(); at the top of each page you want to have sessions.

When you have someone Log out of the page you can do a simple session destroy like

Code: Select all

<?php

  $old_user = $valid_user;  // store  to test if they *were* logged in
  $result = session_unregister("valid_user");
  session_destroy();
<meta http-equiv="refresh" content="0;URL=killsession.php">

?>
I have it refresh to a killsession page which just has

Code: Select all

<?php

header ("Location: /index.php");

?>
This kills the session for sure so they can not hit the back button and still have a session. If you have more questions please email me at jerry@coastgames.com. If you need help setting up more of this type of page happy to help you with your code if needed.

Posted: Thu Feb 20, 2003 12:40 pm
by molandim
Very thanks man... I will do this with mysql.....