dongpiaozhao6836 2013-11-24 16:43
浏览 61
已采纳

如何防止同时查看两个页面

I've media website once member is logged successfully it creates session

$_SESSION['login_id'] = $username;

I wonder how to prevent members to watch two channels in same time.

I mean for example if member is viewing page video.php?id=4 and open in new tab page video.php?id=5 it shows him error have to close the page of video.php?id=4 before viewing the new page.

1st thing came into my mind is random token key that cleared on page exit but i don't know if it good idea or not, does anyone known how to do it or have better idea ! ~ thanks

  • 写回答

3条回答 默认 最新

  • drne47241 2013-11-24 16:49
    关注

    At first thought

    You could use requests to a php script that tells you if the user is still opening a web page.

    For that you can use a loop of timed out ajax requests ( using jQuery for example)

    Hint:

    Instead of making Requests you can try and load tiny images ( 1px h/w ) and of course load this image using a php script (you can trick the url using htaccess), So when the image is requested, your php script will do the trick (setting the currently watched video) then serve the image (don't forget to set the proper content-type )

    and keep loading the image at certain interval (you will need to generate url token to avoid caching ;) )


    A second solution could be

    Serving your videos using php script as proxy, like that you can know when a video has been streamed completely, then if a user request a second video, knowing his is still streaming a previous one, you deny his request, show him an appropriate message or do as you like :)

    I guess, using the 2nd solution would be better for you and the visitor, since he would be able to start caching a 2nd video once the 1st one has been cached completely

    1st solution will use many request which can overwhelm the network or both the client side and server side


    Both Solutions would not track a user that is using more than one browser, which means he would have more than one session, unless the user is registered and logged in

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)