douke1891 2016-09-13 20:44
浏览 116

设置cookie以保存用户语言选择并重定向到所选页面而不是主页[关闭]

I am in the process of making a region selector to allow users to select what region/language they would want to view our website in. The part I am stuck at is trying to have a cookie be in place so that as soon a user selects a region (China for example) whenever they try to access the home domain again, they will automatically get redirected to the region they have previously chosen before.

Would it be possible to have some assistance to get started?

  • 写回答

3条回答 默认 最新

  • douweng3564 2016-09-13 21:31
    关注

    You should be able to do this either server side or client side. I would think server side would be a better way of doing it. When homepage is hit you would first check for lang cookie and if set redirect them to the correct lang specific homepage. Should be fairly straight forward.

    Something like this. Or use a switch statement if you have a lot of languages

    if($_COOKIE['lang'] === 'CHN') {
    header('Location: /chn/index.php');
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度