开发者

Session Problem with multiple Tabs

开发者 https://www.devze.com 2023-03-20 12:29 出处:网络
I have a search on my page where you have a filter Menu, a option for sorting, and a Pagebrowser. The Customer wanted, that if he searches something and clicks on a product and then clicks \"back\" or

I have a search on my page where you have a filter Menu, a option for sorting, and a Pagebrowser. The Customer wanted, that if he searches something and clicks on a product and then clicks "back" or on "search" again, that the same search and results are shown again.

I dont want to pass all the Search Params with each link (bad urls), so I store all this data in the session. This works fine but there is one Problem:

A users 开发者_Python百科opens the search and filters by "size=big" then opens a new tab and changes the filter to "size=small". There is now "size=small" in his session. So if he switches back on his first tab and clicks "page 2" there, then he sees the second page, but not for "size=big" as he expected, but for "size=small".

Is there a nice way to fix this without passing all the variables (many!) around all the time?


I would strongly suggest putting the search in your link. It might make your links less »beautiful«, but I hate it when I can't send a search result to a friend by simply sending the link.

But to answer your question: Put a search_id in every form, that gets appended to the url. Then save the search in the session for that specific search_id. When the user refreshes the page, you can check if POST search variables are transmitted, or if there is one stored in the session for that specific search_id.


No. right now, browsers implement cookies across all tabs, so you cannot have different cookies or sessions on different tabs. Thus, the only way to store state is on the url.

0

精彩评论

暂无评论...
验证码 换一张
取 消