I am working on a project where a lot of things are dependant on cookies. We have a weird requirement at the moment. Our customer can log in with different user id in a different tab.
Important: sessionStorage is the best way to store but sometimes we are losing data while routing and many other cases, so we started keeping data in sessionStorage as well as cookies
Using angular 2 and 6
Issues/Questions:
Since everything is based on cookies, the data between the different users are getting shared with each other and resulting in the business loss. Is there any better approach to handle, store data instead of cookies?
To resolve issue 1 we used this approach: When the users already logged in, and try to login in another tab with different user id, we show a popup saying "you have logged in with another user id. do you want to log in again?". If the user clicks the "Yes" button, we will activate the current tab and deactivate the last tab user session.
But the problem here is there are many cases where we need to delete a particular cookie. I tried Jquery-cookie plugin, ng2-cookies as well as setting an expiry but every time I open the application in chrome dev tool I see the cookie available and not deleted. Whenever I access deleted cookie I get the cookie and the logic fails.
So, the second question is; what is the better way to delete a cookie? I have tried ng2-cookies`, jquery-c0okie and setting expiry but no luck in deleting a cookie.