0

How do i set a cookie if the url has a query string '?no_redirect=1'?

I'm not getting any cookies being set. Currently i have

function cookieQuery() {
    var referrer = "//domain.local";
    if (document.referrer) {
        var no_redir = 'no_redirect';
        var url = window.location.href;
        if(url.indexOf('?' + no_redir) != 1)
            return true;
        else if(url.indexOf('&' + no_referral) = 1)
           $.cookie('no_referral', 'true');
                }
            }
2
  • And what happens to your code? Commented Apr 24, 2013 at 16:47
  • what is the question? Commented Apr 24, 2013 at 16:52

1 Answer 1

1

You are using the assignment operator and not the comparison operator on this line: else if(url.indexOf('&' + no_referral) = 1)

change it to else if(url.indexOf('&' + no_referral) == 1) and assuming the rest of your code is correct, it should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.