Skip to content

Instantly share code, notes, and snippets.

@erguotou520 erguotou520/app1.js Secret
Last active Dec 6, 2017

Embed
What would you like to do?
cookie测试
var fs = require('fs')
var http = require('http')
var https = require('https')
var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
app.get('/', function (req, res) {
console.log(req.cookies)
// res.cookie('name', 'tobi', { path: '/' })
res.end('Hello, express')
})
https.createServer({
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
}, app).listen(8443, function () {
console.log('App started.')
})
http.createServer(app).listen(8111, function () {
console.log('Http app started.')
})
var fs = require('fs')
var https = require('https')
var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
app.get('/', function (req, res) {
console.log(req.cookies)
res.end('Hello, express')
})
https.createServer({
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
}, app).listen(9443, function () {
console.log('App started.')
})
var fs = require('fs')
var https = require('https')
var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
app.get('/abc', function (req, res) {
console.log(req.cookies)
res.cookie('name', 'abc', { path: '/abc' })
res.end('Hello, express')
})
app.get('/def', function (req, res) {
console.log(req.cookies)
res.end('Hello, express')
})
https.createServer({
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
}, app).listen(7443, function () {
console.log('App started.')
})
var fs = require('fs')
var https = require('https')
var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
app.get('/abc', function (req, res) {
console.log(req.cookies)
res.end('Hello, express')
})
https.createServer({
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
}, app).listen(6443, function () {
console.log('App started.')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.