“cara cookie set di node js” Kode Jawaban

Atur cookie di node

res.setHeader('Set-Cookie','visited=true; Max-Age=3000; HttpOnly, Secure');
Scary Snail

cara cookie set di node js

const express('express')
    , cookieParser = require('cookie-parser'); // in order to read cookie sent from client

app.get('/', (req,res)=>{

    // read cookies
    console.log(req.cookies) 

    let options = {
        maxAge: 1000 * 60 * 15, // would expire after 15 minutes
        httpOnly: true, // The cookie only accessible by the web server
        signed: true // Indicates if the cookie should be signed
    }

    // Set cookie
    res.cookie('cookieName', 'cookieValue', options) // options is optional
    res.send('')

})
Dizzy Dog

Jawaban yang mirip dengan “cara cookie set di node js”

Pertanyaan yang mirip dengan “cara cookie set di node js”

Lebih banyak jawaban terkait untuk “cara cookie set di node js” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya