Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

loom's avatar
Level 4

Losing authenticated session. Invalid column name user_id in sessions table

I'm somewhat randomly but very often having my login dropped (longest login session has lasted about a minute). Using database for sessions and database is SQL Server. Running app with Wamp on windows. Using out of the box Laraval authentication. After a short period I'm sent to the log in screen, there is still a login session in the database, and I see the following in larval.log:

================================== [2016-08-11 01:05:46] production.ERROR: exception 'PDOException' with message 'SQLSTATE[42S22]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid column name 'user_id'.' in D:\wamp\www\DCAT\vendor\laravel\framework\src\Illuminate\Database\Connection.php:441 Stack trace:...

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42S22]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid column name 'user_id'. (SQL: insert into [sessions] ([payload], [last_activity], [user_id], [ip_address], [user_agent], [id]) values (YTo0OntzOjY6Il90b2tlbiI7czo0MDoiMUhHRDBkQXZLRnFaS0ZxUW9McEZmUE43YlZJQTdZRm13Vm9tWnFCRyI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6Mjk6Imh0dHA6Ly9zYXNtZXRybzE6MzAwNi9jYXRhbG9nIjt9czo5OiJfc2YyX21ldGEiO2E6Mzp7czoxOiJ1IjtpOjE0NzA4Nzc1NDY7czoxOiJjIjtpOjE0NzA4Nzc1NDY7czoxOiJsIjtzOjE6IjAiO31zOjU6ImZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=, 1470874545, , 123.123.123.123, Mozilla/4.0 (stuff), 001f11f79fcf1a025a604d863677e1f500be1b53))' in D:\wamp\www\DCAT\vendor\laravel\framework\src\Illuminate\Database\Connection.php:713 Stack trace:… =============================

Yes, there is a 'sessions' table. Yes, there is a column 'user_id' and is nullable (above query inserting blank). Yes, it gets populated. If I log back in everything is hosed I assume because there is multiple session instances of the same user so I have to clear the sessions table and clear cookies before I can retest the random yet consistent failure.

This generally happens after a post (I've turned off csrf with ajax routes because I saw some errors with that but it didn't help), a page refresh, or simply going back and forth between pages that need authentication.

This is not happening with the same app on my dev environment. I've been banging my head for three days and people are waiting.

Does this look familiar to anyone?

Thanks

0 likes
1 reply
loom's avatar
loom
OP
Best Answer
Level 4

Looks like random connection errors. Also saw invalid encryptor errors. Ran [ php artisan config:cache ] and all seems good now.

Please or to participate in this conversation.