简体   繁体   English

要在许多IP中长时间保持浏览器会话,我该怎么做/设置?

[英]What do I have to do/set to keep browser's session for a long time among many IPs?

Imagine the following scenario: 想象以下情况:

1) User comes to a site 1)用户来到一个网站
2) User adds 5 products to their cart on the site: 2)用户在网站上的购物车中添加了5种产品:

session_start();
$_SESSION['cart'] = array(1,4,7,12,20);

3) User closes the lid of their laptop and puts the PC to sleep 3)用户合上笔记本电脑的盖子,使PC进入睡眠状态
4) 8 hours pass 4)通过8小时
5) User moves to another location, another internet connection, another IP 5)用户移至另一个位置,另一个Internet连接,另一个IP
6) User opens the lid of their laptop, resuming the browser 6)用户打开笔记本电脑的机盖,恢复浏览器
7) The products are still in the cart 7)产品仍在购物车中

How do we achieve that the step 7 can/will happen? 我们如何实现步骤7可以/将会发生?

  1. session_cart_id(rand) set cookie with session_cart_id independent from session, long living, persistent etc. (like rememberme cookie for login) session_cart_id(rand)设置具有session_cart_id的cookie,与会话,寿命长,持久性等无关(例如,记住我的cookie用于登录)
  2. store somewhere session_cart_id -> cart content 将session_cart_id存储在某处->购物车内容
  3. on session start, load items from store, if session_cart_id isset 在会话开始时,如果设置了session_cart_id,则从商店中加载项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM