dongyue7796 2017-01-22 13:30
浏览 48

PHP中的跨域验证

I am currently working on a project that revolves around the following:

Page 1 ( domain1 ) redirecting to Page 2 ( domain2 ) redirecting to Page 3 ( domain2 )

I wanna make sure that the Page 2 contents is NOT shown unless the user is confirmed to have visited Page 1 first. For obvious reasons, I cannot use sessions and cookies, since domain1 and domain2 are two separate domains.

$_SERVER['HTTP_REFERER'] is a possible solution, but it can be modified or even stripped from the browser requests, so I have no guarantee I won't inadvertently block legitimate users by using it.

How would I go about doing it?

  • 写回答

1条回答 默认 最新

  • duanliang4009 2017-01-22 13:58
    关注

    Yes. You cannot set cookie without direct request from browser.

    You can pass a token while redirecting from http://page1 to http://page2/?token=hash_function($salt,$user_ip).

    More complex way is to generate token on domain with page1 and recheck it with direct request from page2 server to page1 server. This allows you to create "one-time" tokens and even user changed his ip during session (really rare case) - this redirect still be valid.

    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了