Http is a stateless protocol!
this means there is limited means to save state between pages. These are
- is to send information from one page to the next.
- is to allow the server to save some information on your machine that lets the server now who you are and what you are doing. (cookies)
This applies to sessions as well. If you want to allow the user to browse around your pages without logging on everytime. then
1. they have to have cookies on
or
2. you have to send the session ID (SID) on every page in your site. As soon as the user links to a page without an included SID that SID will be lost (unless you go BACK). Posting the session id is as simple as
this little piece of php writes the current URL with the session ID.
<? print "$PHP_SELF"."?".SID; ?>>
this is the first line of a form that links to another URL
<P><FORM NAME="products" METHOD="post" action= <? print "add_product.php"."?".SID; ?>>
It's probably worthwhile adding the SID to all links from your php pages as it works with or without cookies without any further work.
Have a go at the tutorial at:
http://www.phpdeveloper.org/view_tut.php?id=41
There is no password encrytion or session variables in the example but it demonstrates the typical structure of a login script. After that maybe try registering session variables with:
eg.
session_register( "userID" );
let me know how you go.