JQuery Expire Cookie

Help!

I'm trying to use JQurery to expire cookie and redirect, but the script isn't working?

$("a.LogOut").click(function () {
$.cookie("UserAuth", { expires: -1 });
var url = "http://www.google.co.uk/";    
$(location).attr('href',url);
});

Open in new window


Any ideas?

Thanks
garethtnashAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Try this

$.cookie("UserAuth", null, { path: '/' });

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garethtnashAuthor Commented:
Hey Julian,

Thanks, but sorry - no joy, nothing happens -

//////////////////////////      Log Out     /////////////////////////////////

$("a.LogOut").click(function () {
$.cookie("UserAuth", null, { path: '/' });
var url = "http://www.google.co.uk/";    
$(location).attr('href',url);
});

Open in new window


but if i remove the

$.cookie("UserAuth", null, { path: '/' });

Open in new window


the page redirects

Might help, the cookies were originally created in VBscript..

		        Response.Cookies("UserAuth")("Userid")= arrLogin(1,candlogin)
    		    Response.Cookies("UserAuth")("Authentication")= arrLogin(2,candlogin)
    		    Response.Cookies("UserAuth")("UserEmail")= arrLogin(3,candlogin)
    		    Response.Cookies("UserAuth")("LoggedIn")=Date

		        ' If request("rememberme") is null then
		        If IsNull(request("SignInRememberMe")) Then
        		    Response.Cookies("UserAuth").Expires = dateAdd("n", 20, Now())
		    	end if

Open in new window


Also the strange thing with the above, is that the cookies don't expire after 20 minutes if SignInRememberMe is NULL?

Thanks
Julian HansenCommented:
Thanks, but sorry - no joy, nothing happens -
Did you check the console for errors?
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

garethtnashAuthor Commented:
Yeap -

Uncaught TypeError: $.cookie is not a function(anonymous function) @ jqueryscripts-min.js:693x.event.dispatch @ jquery.min.js:5x.event.add.v.handle @ jquery.min.js:5
Julian HansenCommented:
Just checking - have you included the jQuery Cookie plugin?
garethtnashAuthor Commented:
Solved !

Thank you
garethtnashAuthor Commented:
Excellent
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.