检测查看相同网页或URL的用户 [英] Detect Users Viewing Same Webpage, or URL

查看:114
本文介绍了检测查看相同网页或URL的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个票务系统,该系统将允许任何用户查看他们希望选择的任何票证.每个票证将共享同一页面. (例如ticket.php)URL将包含用于标识票证的唯一参数.例如:/ticket.php?a=10000&tid=987654.其中,tid是票证编号.我想检测是否有多个用户正在查看票证,如果条件为真,则将其显示为网页中的通知.我该怎么做呢?我必须使用PHP Server变量吗?会话变量? Javascript?都是吗?

I have a ticketing system that will allow any users to view any ticket they wish to select. Each ticket will share the same page. (ex. ticket.php) The URL will contain unique parameters to identify the ticket. For an example: /ticket.php?a=10000&tid=987654. Where tid is the ticket id number. I would like to detect if more than one user is viewing the ticket and show this as a notification in the webpage if the condition is true. How do I go about doing this? Would I have to use PHP Server variable? Session variable? Javascript? Both?

推荐答案

Ajax和服务器变量应该可以解决问题.

Ajax and server variable should do the trick.

在加载时,您更新服务器变量 在卸载更新服务器变量 在页面上时,Ajax会不断更新具有当前状态的网页

On load you update server variable On unload update server variable When on page Ajax keeps updating webpage with current status

看看这篇文章.您要做的就是将其中一个array_map存储在一个以页面名称为键的服务器变量中.

Have a look at this post. All you have to do is store one of these array_map in a server variable with page name as the key.

在PHP中是否有等效的Java HashMap?

这篇关于检测查看相同网页或URL的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆