javascript - avoiding setting a cookie based on a specific URL string -
I am setting a cookie based on user, before visiting any website. So every time a new user goes to the website, I am redirecting them to the landing page or else the user will see the index page directly (since the cookie is already in the user's browser).
Now what I am trying to achieve is that I would like to leave the landing page redirect on a specific URL (for both new users and existing users).
In this way I am checking new visits and setting up a redirect cookie.
$ (document) .ready (function () {landingPageOnFirstVisit (); createCookie ('landingRedirect', 'true', '60');}); Function LandingPageOnFirstVille () {var Set CookiesFor Landing = Redduck ('Landing Redirect'); If (! SetCookieForLanding) {window.location = "/ en / landing"; }} Creating a cookie cookie (name, value, day) {if (day) {var date = new date (); Date.setTime (date.getTime () + (Days * 24 * 60 * 60 * 1000)); End of var = "; has expired" = "+ date.toGMTString ();} Completion of other var =" "; Document.cookie = name +" = "+ value + finished +"; Path = / ";} read the function (name) {var nameEQ = name +" = "; var ca = document.cookie.split (';'); for (var i = 0; i & lt; ca.length ; I ++) {var c = ca [i]; while (c.charAt (0) == '') c = c.substring (1, c.length); if (c.indexOf (nameEQ) == 0) Return c.substring (nameEQ.length, c.length);} Return Null;} How can I ensure that if the user uses the URL pattern mentioned directly below on the website Does: Redirecting is not processed and we do not set any cookies.
(Where XXXXXX numbers are and are not in place at all
Try
$ (function () { If (location.href.indexOf ("usePromo") == - 1) {Landing PageOnFirst Visit (); Creating Links ('Landing Redirect', 'True', '60');}});
Comments
Post a Comment