PHP Sessions

Due: 11:00pm, Monday, November 28, 2022

Assignment Description

The goal of this assignment is to use PHP session variables to maintain application state on the server. The files that you need to edit are: index.php, create_account.php, sign_in.php, and log_out.php. Instructions for what you need to do in each file are in code comments that start with TODO. Some of the instructions say to redirect to another page in the application. The way to do this in PHP is to set an HTTP header and then exit the program like so:

    header("Location: page_to_redirect_to.php");
    exit();

The user.db file needs to have write permissions in order for the PHP programs to write to the file. To enable write permissions, execute the following two commands from within the project9-handout directory:

    chmod ugo+w user.db
    chmod ugo+w .

Note: this assignment stores the user’s passwords in the database. You should not do this for a real website. We will discuss the appropriate way to store passwords in a database.

Instructions

To start the assignment, login to your university Linux account and copy the assignment code to a location somewhere under your public_html directory. The assignment code is located at:

/export/home/public/schwesin/csc242/projects/project9-handout

You need to edit the index.php, create_account.php, sign_in.php, and log_out.php. files. Do not change the names of any of the files.

To submit your assignment, execute the following command from within your project8-handout directory:

    ~schwesin/bin/submit csc242 project9

Grading Criteria

Note: If the code has syntax errors or does not execute properly (this includes warnings from PHP interpreter), you will receive a failing grade for this assignment. If the submission includes material that was not covered in class and the material is not properly cited, then you will receive a failing grade for this assignment.