Click here to Skip to main content
15,868,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want go to 'cart.aspx' page from 'country.apsx' by

<a id="linkCart" href="cart.aspx">cart</a>


but in 'cart.aspx' i am checking cookie value by

C#
var userCookie = getCookie('loggedInUser');
        function getCookie(name) {
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < 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;
        }
        if (userCookie == null) {
            window.location.href = "loginpage.aspx";
        }


then if cookie value null then have to go 'login.aspx' page otherwise load this 'cart.aspx' page only

but when I click on 'cart' (anchor tag) then first displaying cart page then displaying loading.aspx page after condition is get true..

where as have to display directly 'login.aspx' page without display 'cart.aspx' page. so what to do?
Posted
Comments
KaushalJB 21-Oct-15 6:09am    
What value do you get here ?

var ca = document.cookie.split(';');

Check for the cookie when the page load in cart.aspx
 
Share this answer
 
v2
Then you should check the cookie in country.aspx itself.

Add a JavaScript click event handler for cart link.

In that click event, check if cookie exists or not. If found, go to cart.aspx, else go to login.aspx.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900