Express JS - Track Recently Visited Pages in Session
When a user visits any web page, save the page name and URL in the session as an array of objects. Each object should contain the page name and URL. Create a footer.ejs file to display the list of the 10 most recently visited pages in the footer of every EJS page. Each page should appear as a clickable hyperlink in a separate row.
- If the user clicks on a link, the corresponding page should open.
- At the end of the list, include a "Remove All" link to clear the list of recently visited pages in the session.
- Add an "X" next to each link to allow the user to remove that specific page from the session.
- After removing a page or clearing the list, redirect the user to the /home page.
If a user visits a page that is already in the list, move it to the top and remove the previous occurrence to avoid duplicates.
Comments
Post a Comment