Simple login with sessions tutorial
Moderator: General Moderators
Simple login with sessions tutorial
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.
the link PHP Tutorials on top of this page takes you e.g. to http://www.phpcomplete.com/tutorials.ph ... adTutorial 
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
I have it refresh to a killsession page which just has
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.
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">
?>Code: Select all
<?php
header ("Location: /index.php");
?>