Questions tagged [js-cookie]

A simple, lightweight JavaScript API for handling cookies (previously called jquery-cookie)

A simple, lightweight JavaScript API for handling cookies (previously )

Feature Overview

  • Crossbrowser
  • Doesn't rely on any framework
  • Supports ES modules
  • Supports AMD/CommonJS
  • RFC 6265 compliant

Documentation & Links

130 questions
11
votes
2 answers

Firefox and Chrome error when linking js-cookie: Uncaught ReferenceError: module is not defined

Error in the console log: "Uncaught ReferenceError: module is not defined" This is what is causing the error: Does this happen to anyone else on…
Yi Zong Kuang
  • 544
  • 1
  • 6
  • 17
10
votes
1 answer

How to store, read and delete cookies and sessions in Nest.js

How to store, read and delete cookies and sessions in Nest.js? Should I use this: @nestjs/common > session Or should I use js-cookie?
东方不败
  • 115
  • 1
  • 4
8
votes
2 answers

Typescript using the incorrect type with jest when there are multiple available

I am new to typescript and noticed a behaviour I wasn't expecting. When I go to mock a named import with the js-cookie package, it mocks a particular instance of the property, but incorrectly chooses the correct type to use. import Cookies from…
Charklewis
  • 4,427
  • 4
  • 31
  • 69
5
votes
0 answers

How to access session token with next-auth in order to attach it to a API request header?

Hello I'm new to NextJS and React, but my project currently has a 3rd party api that I'm working with that requires a session token input in the header for all requests. So I picked next-Auth for authentication but I have problem accessing that…
Fanta
  • 51
  • 2
5
votes
2 answers

How to correctly require js-cookie with npm and webpack? Uncaught ReferenceError

Strange problem but I'm sure it's easily solved. I've tested on a completely empty webpack project. It says npm js-cookie has 0 dependencies so I guess this should work on its own. $ npm install js-cookie --save Then simply ran this in my script…
joshmoto
  • 4,472
  • 1
  • 26
  • 45
5
votes
2 answers

js-cookie library working on Android but not iOS devices

I am building a web app that uses js-cookie. I use the following to import the js-cookie library into my html/javascript file: My js-cookie code works…
SpeedGolfer
  • 255
  • 3
  • 13
5
votes
4 answers

"Cookies not defined" in standalone js-cookie javascript lib?

I am not a javascript guru, but try to use js-cookie. I included the script: https://github.com/js-cookie/js-cookie: I downloaded it (LINK), and put it in my own js file on the server. I then include it in a test file and read some cookie, but it…
edbras
  • 4,145
  • 9
  • 41
  • 78
5
votes
3 answers

jscookie.js how to expire cookie in minutes not days?

I'm using this jquery cookie named jscookie.js and I've read over the readme and even implemented into my project. The readme explains how to expire a cookie in 'days', but not hours or minutes. Create a cookie that expires 7 days from now, valid…
ConfusedDeer
  • 3,335
  • 8
  • 44
  • 72
5
votes
0 answers

js-cookie: Cookies.get('cookieName') returns undefined

I'm using this library for a JQuery plugin I'm coding... I save inside a cookie a specific data created by the user in this way: // Update cookies checks if the cookie esists. // If cookie exists => push data {myData:[obj1[, obj2, [...], objN]]} //…
IlGala
  • 3,331
  • 4
  • 35
  • 49
4
votes
1 answer

Set and Get array from cookies with js-cookie and JSON.parse

I'm using js-cookie to store data and get them back, I'm trying to sore an array variable but I have trouble mantaining its format. This is the process that create, retrive, change and save data of the cookie, it works but just the first time, as…
Artemis
  • 589
  • 1
  • 6
  • 19
4
votes
2 answers

ReferenceError: Cookies is not defined

When I try to use js-cookie, my javascript file can't seem to track down the Cookies variable from js.cookie-js.js. In my index.html file, I reference the script using this line of code:
Marty
  • 133
  • 1
  • 2
  • 7
4
votes
3 answers

Middleware on specific page - NuxtJS

Well, I'm starting with nuxt and I have following routes: /home /dashboard /login I want to protect the /dashboard, but only for users logged in with a token in Cookie. Then i created a middleware /middleware/auth.js import Cookie from…
Yung Silva
  • 1,324
  • 4
  • 20
  • 40
4
votes
4 answers

Remove cookie problems JS-COOKIE

JS Cookies remove cookie, undefined Hi Guys, I have trying to remove a cookie from a domain but I can't, the console return undefined. When I log in the cookie is set up in .dev.books.com but after that the URL change to platform.dev.books.com and…
rodboc
  • 459
  • 1
  • 8
  • 19
3
votes
4 answers

How to store a long string in Js Cookies?

Hi I am working with JsCookies it is working good but I am facing a problem Whenever I store a short string in the cookies, it is working fine but the drawback is i am not able to store long strings in cookies for example This is working fine =…
dev
  • 109
  • 5
3
votes
2 answers

i want to get my jwt value from cookies in browser

i have now stored my jwt in cookies when user sign in or sign up but the data don't stay so i made a function to handle this but i need the value of the token to make it work this is the function that i need token value for const setAuthToken =…
mohamed nageh
  • 593
  • 4
  • 9
  • 26
1
2 3
8 9