如何在我使用切换语言时保持用户登录 [英] How to keep user logged in when I have a switch language

查看:77
本文介绍了如何在我使用切换语言时保持用户登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我登录了我的网站电子商务,当我切换语言时:例如加泰罗尼亚语,我失去了与帐户的连接,



我'我试图在我的购物车中保持当前帐户与我的rticles会话。



事实上,如果我在普通浏览器上这样做,并且我从语言切换到另一个,一切都很好,



但问题来自于我在私人浏览器上工作,



和这里是我的脚本代码,



所以如何解决这个问题,保持我目前的联系?



我尝试过:



I am logged in my website e-commerce, and when I switch language: to Catalan for example, I lose my connection to the account,

I'm trying to keep the current account session with my rticles in my cart.

In fact, if i do it on normal browser, and i switch from language to another, all is good,

but the problem comes when i work on the private browser,

and here is my code in script,

so how can i fix this problem, to keep my current connexion ?

What I have tried:

<pre>function changeLang(culture, subdomain) {          
        var url = window.location.href;

        var alternate = $('head').find('link[rel="alternate"][hreflang="' + culture + '"]');
        if (alternate && alternate[0]) {
            url = alternate[0].href;
        }
        else {              
            var hostName = window.location.hostname.replace(window.location.hostname.split('.')[0], subdomain);
            url = url.replace(window.location.hostname, hostName);
        }           
        createCookie('IdKids.Culture', culture, 180);          
        window.location = url ;

    }

推荐答案

' < span class =code-string> head')。find(' link [rel =alternate ] [hreflang =' + culture + ' ]');
如果(替代&& alternate [ 0 ]){
url = alternate [ 0 ]。href;
}
其他 {
var hostName = window location .hostname.replace( window location .hostname.split(' 。') [ 0 ],子域名);
url = url.replace( window location .hostname,hostName);
}
createCookie(' IdKids.Culture',culture, 180 );
window location = url;

}
('head').find('link[rel="alternate"][hreflang="' + culture + '"]'); if (alternate && alternate[0]) { url = alternate[0].href; } else { var hostName = window.location.hostname.replace(window.location.hostname.split('.')[0], subdomain); url = url.replace(window.location.hostname, hostName); } createCookie('IdKids.Culture', culture, 180); window.location = url ; }


听起来你正在与浏览器的私人窗口功能作斗争。如果它不在私人窗口时工作,我会说你无法解决它。当你覆盖cookie时,你会得到一个新的私人会话
It sounds like you're fighting the private window functionality of the browser. If it works when you're not in a private window, I'd say you can't fix it. You get a new private session when you overwrite the cookie would be my guess


这篇关于如何在我使用切换语言时保持用户登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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