0
我正在使用expressjs的connect-mysql-session模塊。對於每個請求給服務器,我得到這個:帶有connect-mysql-session的Expressjs
Express server listening on port 3000 in development mode
Executing: CREATE TABLE IF NOT EXISTS `Sessions` (`sid` VARCHAR(255), `expires` INT, `json` TEXT, `id` INT NOT NULL auto_increment , `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
MySQL session store initialized.
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: UPDATE `Sessions` SET `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo',`expires`=1323327347,`json`='{\"lastAccess\":1323312946989,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-12-08T06:55:47.013Z\",\"httpOnly\":true,\"path\":\"/\"},\"status\":true,\"_csrf\":\"kzvoTUf88Nr36YR2g7w6Y9P8\"}',`id`=9,`createdAt`='2011-12-08 03:52:11',`updatedAt`='2011-12-08 03:55:47' WHERE `id`=9
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: UPDATE `Sessions` SET `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo',`expires`=1323327347,`json`='{\"lastAccess\":1323312947060,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-12-08T06:55:47.061Z\",\"httpOnly\":true,\"path\":\"/\"},\"status\":true,\"_csrf\":\"kzvoTUf88Nr36YR2g7w6Y9P8\"}',`id`=9,`createdAt`='2011-12-08 03:52:11',`updatedAt`='2011-12-08 03:55:47' WHERE `id`=9
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: UPDATE `Sessions` SET `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo',`expires`=1323327347,`json`='{\"lastAccess\":1323312947088,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-12-08T06:55:47.089Z\",\"httpOnly\":true,\"path\":\"/\"},\"status\":true,\"_csrf\":\"kzvoTUf88Nr36YR2g7w6Y9P8\"}',`id`=9,`createdAt`='2011-12-08 03:52:11',`updatedAt`='2011-12-08 03:55:47' WHERE `id`=9
Executing: UPDATE `Sessions` SET `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo',`expires`=1323327347,`json`='{\"lastAccess\":1323312947089,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-12-08T06:55:47.090Z\",\"httpOnly\":true,\"path\":\"/\"},\"status\":true,\"_csrf\":\"kzvoTUf88Nr36YR2g7w6Y9P8\"}',`id`=9,`createdAt`='2011-12-08 03:52:11',`updatedAt`='2011-12-08 03:55:47' WHERE `id`=9
Executing: UPDATE `Sessions` SET `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo',`expires`=1323327347,`json`='{\"lastAccess\":1323312947114,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-12-08T06:55:47.115Z\",\"httpOnly\":true,\"path\":\"/\"},\"status\":true,\"_csrf\":\"kzvoTUf88Nr36YR2g7w6Y9P8\"}',`id`=9,`createdAt`='2011-12-08 03:52:11',`updatedAt`='2011-12-08 03:55:47' WHERE `id`=9
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: SELECT * FROM `Sessions` WHERE `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo' LIMIT 1;
Executing: UPDATE `Sessions` SET `sid`='4SQXzLCo1O44CLMdrA1WjVVC.lecbAd5SOXHkyJfR+YEpIVJ8p9E8m79TAGGTwxnoCuo',`expires`=1323327347,`json`='{\"lastAccess\":1323312947253,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-12-08T06:55:47.254Z\",\"httpOnly\":true,\"path\":\"/\"},\"status\":true,\"_csrf\":\"kzvoTUf88Nr36YR2g7w6Y9P8\"}',`id`=9,`createdAt`='2011-12-08 03:52:11',`updatedAt`='2011-12-08 03:55:47' WHERE `id`=9
爲什麼這樣做呢?
而且我還爲每個請求設置了約8個Cookie(connect.sid),我認爲它爲每個資產likje js,css和圖像設置。爲什麼它被設置了這麼多次?它是否支持?
繼承人我的配置:
app.set('views', __dirname + '/../views');
app.set('view engine', 'html');
app.register('.html', require('ejs'));
app.use(express.bodyParser());
app.use(expressValidator);
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({
store: new MySQLSessionStore("test_db", "root", "root"),
secret: 'cat'
}));
app.use(app.router);
app.use(express.csrf());
app.use(express.static(__dirname + '/../public'));
問候
確實是這個問題。現在它只執行兩次,必須找出它在哪裏做。它也擺脫了餅乾問題:)我必須讀更多的東西:/謝謝你的回覆:) – georgesamper