cookies记载用户阅读产品ITeye - AG环亚娱乐

cookies记载用户阅读产品ITeye

2019-01-11 19:23:16 | 作者: 依波 | 标签: 阅读,前史,记录 | 浏览: 358

http://www.schooltop.net/blogs/292
before_filter :browse_product_history #阅读前史记录
 # 调用cookies[:browse_product_history]回来chemical的前史阅读序列(从新到旧),用/离隔,
 def browse_product_history
 cookies.delete :browse_chemicals_history if cookies[:browse_product_history] =~ /EBD/
 if params[:controller] == "products" params[:action] == "show"
 product_id = params[:id]
 if cookies[:browse_product_history].blank?
 history = product_id + "/"
 cookies[:browse_product_history] = { value: history, expires: 20.years.from_now }
 else
 history_array = cookies[:browse_product_history].split("/")
 if history_array.size 6
 if history_array.include?(product_id)
 history_array.delete(product_id)
 history_array.unshift(product_id)
 else
 history_array.unshift(product_id)
 else
 if history_array.include?(product_id)
 history_array.delete(product_id)
 history_array.unshift(product_id)
 else
 history_array.pop
 history_array.unshift(product_id)
 history = history_array * "/"
 cookies[:browse_product_history] = { value: history, expires: 20.years.from_now }                          
			
版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表AG环亚娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章