I have improved my understanding of where programming languages such as JavaScript can be implemented in a useful way. I have greatly improved my way of thinking about a website and how it is buildt up. I have improved my code setup by commenting and implementing things in a useful and general way.
The link to my screencast is here: https://youtu.be/HQXu6mWoxss
My shopping cart will be a separate page where the user can add and remove products, and the products are retrieved from the users session. The cart can be accessed at all time, even when no products are selected (an error message will show), and when the user is not logged in. However, to get to the invoice, the user must be logged in.
The data format used is an object within an object, organized by product type, where each product type has an associated object storing quantities for each product. This structure allows me to easily manage and retrieve shopping cart data for different product types. shopping_cart={Bags: {…}, Towels: {…}, Hats: {…}}
User is authenticated before allowing access to sensitive parts of application (invoice) by using cookie. I am managing security concerns by:
Prevent client-side script access to session (httpOnly
)
Have expiration for session and cookies
No information is stored in the qstr, and only name and email is stored in cookie
User name and email is displayed on products_display when logged in, retrieved from cookie. Example: // Extract and parse the ‘name’ cookie const cookieName = document.cookie.split(‘; ‘).find(row => row.startsWith(‘name=’)); const userName = cookieName ? decodeURIComponent(cookieName.split(‘=’)[1]) : null;
// Update the welcome message based on whether the user is logged in
const welcomeMessage = document.getElementById('welcomeMessage');
if (userName) {
welcomeMessage.innerText = `WELCOME, ${userName.toUpperCase()}`;
} else {
welcomeMessage.innerText = 'WELCOME';
}
I am writing a checklist for everything that needs to be done, and check off when the task is completed. I am also using the debugger more frequently.