Beau D'Amore
Beau D'Amore

Reputation: 3392

JQuery Cookie loads but returns error always

I just get:

8:21 Uncaught TypeError: Cannot read property 'set' of undefined

for:

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
<script src="~/Scripts/jquery.cookie.js"></script>
<script>
    $.cookies.set('TEST', "VALUEEEE", { path: '/' }); // <-- errs here
</script>

I'm in MVC5, tried this directly on a page, in layout, in partial.... no go anywhere... simply get this error no matter what. File is in place from NuGet package and referenced as you see here... Confirmed jQuery loaded, and jquery cookie file loaded...

Screenshot

Cannot get this to work... any ideas?

Upvotes: 1

Views: 99

Answers (2)

Tanvi B
Tanvi B

Reputation: 1567

It should be like below

var cook = $.cookie('TEST', "VALUEEEE", { path: '/' });

Upvotes: 2

blurfus
blurfus

Reputation: 14031

The docs for the library indicate usage to be like this:

$.cookie('name', 'value');

There is no .set(...) function

Upvotes: 1

Related Questions