Authored by ccbikai

不再兼容 PHP session

@@ -17,9 +17,8 @@ const path = require('path'); @@ -17,9 +17,8 @@ const path = require('path');
17 const bodyParser = require('body-parser'); 17 const bodyParser = require('body-parser');
18 const cookieParser = require('cookie-parser'); 18 const cookieParser = require('cookie-parser');
19 const favicon = require('serve-favicon'); 19 const favicon = require('serve-favicon');
20 -const session = require('yoho-express-session');  
21 -const memcached = require('yoho-connect-memcached');  
22 -const uuid = require('uuid'); 20 +const session = require('express-session');
  21 +const memcached = require('connect-memcached');
23 const _ = require('lodash'); 22 const _ = require('lodash');
24 const pkg = require('./package.json'); 23 const pkg = require('./package.json');
25 const cookie = require('./library/cookie'); 24 const cookie = require('./library/cookie');
@@ -50,19 +49,15 @@ app.use(session({ @@ -50,19 +49,15 @@ app.use(session({
50 resave: false, 49 resave: false,
51 saveUninitialized: true, 50 saveUninitialized: true,
52 unset: 'destroy', 51 unset: 'destroy',
53 - secret: 'nothing', // 兼容 PHP SESSION,sessionID 不加密  
54 - name: 'PHPSESSID', // 兼容 PHP SESSION  
55 - genid: () => {  
56 - return uuid.v4(); // 兼容 PHP SESSION  
57 - }, 52 + secret: '82dd7e724f2c6870472c89dfa43cf48d',
  53 + name: 'yohobuy_session',
58 cookie: { 54 cookie: {
59 - domain: 'yohobuy.com', 55 + // domain: 'yohobuy.com',
60 httpOnly: false 56 httpOnly: false
61 }, 57 },
62 store: new MemcachedStore({ 58 store: new MemcachedStore({
63 hosts: config.memcache.session, 59 hosts: config.memcache.session,
64 - prefix: 'qinsessionsession:', // 兼容 PHP SESSION  
65 - key: 'yohobuy_session' // 兼容 PHP SESSION 60 + prefix: 'yohobuy_session:'
66 }) 61 })
67 })); 62 }));
68 63
@@ -33,9 +33,11 @@ @@ -33,9 +33,11 @@
33 "dependencies": { 33 "dependencies": {
34 "bluebird": "^3.4.0", 34 "bluebird": "^3.4.0",
35 "body-parser": "^1.15.0", 35 "body-parser": "^1.15.0",
  36 + "connect-memcached": "^0.2.0",
36 "cookie-parser": "^1.4.3", 37 "cookie-parser": "^1.4.3",
37 "express": "^4.13.1", 38 "express": "^4.13.1",
38 "express-handlebars": "^3.0.0", 39 "express-handlebars": "^3.0.0",
  40 + "express-session": "^1.13.0",
39 "influxdb-winston": "^1.0.1", 41 "influxdb-winston": "^1.0.1",
40 "lodash": "^4.13.1", 42 "lodash": "^4.13.1",
41 "md5": "^2.1.0", 43 "md5": "^2.1.0",