Lab6. Session Management & Access Control
Lab6. Session Management & Access Control
Resources
1. session_mgmt_access_control.zip
3. Select “Directory”, and browse to “C:\xampp\htdocs” and select the “login” folder.
2. Codes drop the existing “ishop” database and recreate a new “ishop.users” table.
Running the php code will recreate “ishop” database
** You will need to manually delete the ishop in C:\xampp\mysql\data\mysql directories if you have an existing
one
3. Launch the browser and access http://localhost/login, the following screen should be
displayed.
5. Codes add a new user ”defaultuser” into the “ishop.users” table by calling the adduser
function defined in fxadduser.php. Running the php code will create a new user account.
4. Enter the necessary information and click on “Submit” button. The information will be
processed by “registerdo.php” The results of your submission will be displayed
5. Run the “fxprintusers.php” code to display the list of users. The new user should be
reflected in the results, like the screen below.
5. Once the processing is completed, the page shows the results like the following
screenshots.
11. Review the $_SESSION and $_COOKIE information. Observe that the session_id and
the cookies remains the same. Hence, session_id and cookies shall not be used to
determine authenticated session. Instead, session variables (e.g. “username” and
“role”) stored in the $_SESSION should be used to determine authenticated sessions.
Authenticated Session (Logged in) Unauthenticated Session (Logout)
3. Input the username and password of a valid account with only user role, e.g. defaultuser.
Enter “defaultuser” in username field and “password” in password field and sign in.
4. Access the page at “http://localhost\login\page4users.php” in the browser. The page
displays results like the following screenshots.
7. Try to sign out and sign in as a user account with role “admin”. Then try to access
http://localhost\login\page4admins.php and observe the results again.