Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Vue js cookies is undefined

I have installed the vue-cookies in my project.

I have included the following in the main.js file:

createApp(App)
    .use(store)
    .use(router, axios, VueCookies)

Then the script part in the App.vue file contains the following:

<script>
import Navbar from '@/components/layout/Navbar'
import axios from 'axios'


export default {
  name: 'App',
  components: {
    Navbar
  },
  beforeCreate() {


    console.log(this.$cookies)

This says cookies is undefined, so I can't set or get any cookies.

If I add a import VueCookies from 'vue-cookies' the result is the same.

Before, I used localStorage, and I used this beforeCreate to read the login information from it. I want to start using cookies to store the token between sessions, as I have read it's more secure.

I have searched arout a little bit I have not read anything regarding cookie initialization or anything else I have to do so that this.$cookies is not undefined.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have never used this library. But looking at npm: https://www.npmjs.com/package/vue-cookies

You have to import the library and use the plugin.

import VueCookies from 'vue-cookies';

Vue.use(VueCookies)

***I assume that you have installed the library previously.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!