thabet idris

thabet idris

  • NA
  • 35
  • 4.8k

How to keep user logged in when i have a switch language

Apr 19 2019 5:00 AM

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,

  1. function changeLang(culture, subdomain) {            
  2.        var url = window.location.href;  
  3.   
  4.        var alternate = $('head').find('link[rel="alternate"][hreflang="' + culture + '"]');  
  5.        if (alternate && alternate[0]) {  
  6.            url = alternate[0].href;  
  7.        }  
  8.        else {                
  9.            var hostName = window.location.hostname.replace(window.location.hostname.split('.')[0], subdomain);  
  10.            url = url.replace(window.location.hostname, hostName);  
  11.        }             
  12.        createCookie('IdKids.Culture', culture, 180);            
  13.        window.location = url ;  
  14.   
  15.    }  
 

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


Answers (1)