Cookies are Becoming Frowned Upon - Use Browser Session Storage

Given the concerns around cookies and their limitations, such as small storage capacity, privacy concerns, and the fact that they can be blocked by users, storing values in a browser session might indeed be a more privacy-conscious and user-friendly alternative. Session storage is a part of the Web Storage API, alongside local storage, and is designed to hold data for the duration of a page session. This means the data is lost once the user closes the tab or browser, which can be advantageous for sensitive information that should not persist beyond a single session.

Session storage is specifically designed for scenarios where you need to store data across multiple pages in a single tab, but unlike local storage, the data is not persistent. This makes it a good choice for storing data that is only relevant for the duration of the user's session, such as form inputs or session tokens. It's also useful for scenarios where you want to avoid the overhead of sending data to the server with every request, as session storage is not sent with HTTP requests.

Here's a simple example of how to use session storage in JavaScript:

// Store data
sessionStorage.setItem('key', 'value');

// Retrieve data
let data = sessionStorage.getItem('key');

// Remove data

// Clear all data

When considering whether to use session storage or cookies, it's important to weigh the benefits and drawbacks of each. Session storage offers a higher storage limit than cookies and is not sent with every HTTP request, which can reduce network traffic. However, it's also important to consider the privacy implications and ensure that any data stored is necessary and that users are informed about how their data is being used.

In conclusion, for storing values that are relevant only during a single session and where privacy is a concern, session storage could be a better choice than cookies. However, it's essential to consider the specific requirements of your application and the user experience implications of using session storage versus cookies