Answers for "nodejs sessions"

PHP
13

php sessions

<?php
  	// Start new or resume existing session.
  	session_start();
	
	// Add values to the session.
	$_SESSION['item_name'] = 'value'; // string
	$_SESSION['item_name'] = 0; // int
	$_SESSION['item_name'] = 0.0; // float

	// Get session values.
	$value = $_SESSION['item_name'];
?>
Posted by: Guest on May-08-2020
5

npm express-session

npm i express-session	//On Hyper/CMD

const session = require('express-session');	//To Acquire it

app.use(session({ 		//Usuage
  secret: 'keyboard cat',
  resave: false,
  saveUninitialized: true,
  cookie: { secure: true }
}));
Posted by: Guest on August-05-2020
0

how can i use sessions in express js

const express = require('express')
const session = require('express-session')

const app = express()
app.use(session({
  'secret': '343ji43j4n3jn4jk3n'
}))
Posted by: Guest on March-04-2021

Browse Popular Code Answers by Language