简体   繁体   中英

How to set Cookie in Electron React using npm react-cookie package?

i am trying to set cookie in electron-react app using npm react-cookie package

and setting cookie like that

import { useCookies } from "react-cookie";
const [cookies, setCookie, removeCookie] = useCookies();
setCookie("isWorking", 121, { path: "/" });

its work fine in development mode but as i build electron application its not set my cookies in build application

SnapShot of cookies in development

SS_of_cookie

Snapshot in Production/electron build application在此处输入图像描述

You can do:

import { useCookies } from 'react-cookie'

// Declare the useCookies hook
const [cookies, setCookie, removeCookie] = useCookies(['name'])

// Set a cookie
setCookie('name', 'value', { path: '/' })

// Retrieve the cookie from `cookies` object
const name = cookies.name

// Remove the cookie
removeCookie('name')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM