0% found this document useful (0 votes)
142 views

Spring 2024 - CS511 - 2

Uploaded by

mahreen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views

Spring 2024 - CS511 - 2

Uploaded by

mahreen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment No.

2 Total Marks: 20

Semester: Spring 2024


Due Date: 24/06/2024
CS511 – Web Engineering

Instructions
Please read the following instructions carefully before submitting the assignment solution:
It should be clear that your assignment will not get any credit/marks if:
o Assignment is submitted after due date.
o Submitted assignment does not open or file is corrupt.
o Assignment is copied (From internet/students).

Assignment Submission Instructions


You have to submit only “.php” file of your code on the assignments interface from your LMS
account.
Assignment submitted in any other format will not be accepted and will be scaled with
zero marks. No excuse will be accepted on submitting solution file in any other format.
For any query related to assignment, please contact [email protected] .

Problem Statement:

Develop a user-friendly online shopping cart system using a single PHP file. Customers can
browse items, add them to their cart, view the cart's contents, and remove unwanted items. The
system should remember the cart items even if the customer closes the browser and returns
within a reasonable timeframe (e.g., 1 hour).

Requirements (5 marks):
1. Session Management:
o Implement session handling using session_id(), session_start(), and
session_status().
o Store a unique session ID in a cookie named "session_id" that expires after a set
time (e.g., 1 hour) using setcookie().
o Check if a session is active at the beginning of your script. If not, redirect the user
to a login page (optional) or display a message indicating they need to start a new
session.
2. Cart with Sessions:
o Create a session variable named "cart" to store an array of product details (ID,
name, price, quantity).
o Update the "cart" session variable when a customer adds or removes items using a
form.
o Ensure proper data type handling to avoid errors (e.g., convert quantities to
integers).
3. View Cart Contents:
o Display the contents of the "cart" session variable in a user-friendly format.
Include product information (name, price, quantity) and calculate the total cost.
o If the cart is empty, display a clear message indicating this.
4. Remove Items from Cart:
o Allow customers to remove items from their cart based on product ID using a
form with a submit button.
o Capture the product ID of the item to be removed.
o Update the "cart" session variable by removing the corresponding item details
from the array.
Ensure that the code is well-commented, follows basic PHP syntax, and follows to the
requirements listed above.

Sample Output:
Weeks Covered: 6 - 10
Due Date: Monday, June 24, 2024.

You might also like