I am new to laravel and coding for 2 two weeks now and stuck in an deployment problem.
My local machine: Windows 10 with PHP Storm, MySql and I am running on artisan serve
On Production it runs on https://www.trim.finance
My Issue is that on local everything works within my program status but live i get the TOKEN Missmatch Error because my Session Key is rewritten every REQUEST. Local the Session looks ok with old Data and the previuos link and so on but live there is just the KEY.
Maybe this is helpful. On Strato i force the website to run on HTTPS an LOCAL i don't because i don't know how i will artisan demand that.
I tried the last days to get it running but don't have a clou. I inserted a button on the end to show session->all() and routet it at /session.
my Shame i uploaded the env File on produktion server to make both more similar.
.env File on Server
APP_ENV=local
APP_LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=**
DB_PORT=3306
DB_DATABASE=**
DB_USERNAME=**
DB_PASSWORD=**
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=mailgun
MAIL_DOMAIN=https://api.**
MAIL_SECRET=key-**
config/app.php on Server
return [
'name' => env('APP_NAME', 'tRIM'),
'env' => env('APP_ENV', 'local'),
'debug' => env('APP_DEBUG', true),
'url' => env('APP_URL', 'https://www.trim.finance'),
'timezone' => 'Europe/Berlin',
'locale' => 'en',
'fallback_locale' => 'de',
'key' => env('APP_KEY', 'base64:KEYCODE'),
'cipher' => 'AES-256-CBC',
'log' => env('APP_LOG', 'single'),
]
config/session.php on Server
return [
'driver' => env('SESSION_DRIVER', 'database'),
'lifetime' => 60000,
'expire_on_close' => false,
'encrypt' => true,
'files' => storage_path('framework/sessions'),
'connection' => 'mysql',
'table' => 'sessions',
'store' => null,
'lottery' => [2, 100],
'cookie' => 'trim_session',
'path' => '/',
'domain' => null,
'secure' => env('SESSION_SECURE_COOKIE', true),
'http_only' => false,
];
Test1: Please try to Register /register to see the Problem. (Every data is fake so feel free to try).
Test2: Try to create a new Adress /create
My debbugging got me so far
The issue ist just on the produktion side. (I allready deleted the hole webServer and copied all data again to see if there is something missing oder online changed.) local it works.
Every get request doen't need the session so no harm.
- BUT i inserted an SESSION button to see the data and every refresh of the page makes a new
session [_token"]
- BUT i inserted an SESSION button to see the data and every refresh of the page makes a new
EveryPost request don't geht through because of the
TokenMismatchException
.- I edited the TokenMismatchException what is matched and every time he generates a new Session _token
- I shortcuted the Token comparison and did'nt get through because Laravels safety features.
Forms are generated with blade like {{Form:model}} or {{Form:open}} which generated
<input type="hidden" name="_token" value="S1d...">
Sessions are stored in the Database for every request one line .. seems too much.. every Session one line it should be. Here an Example from my database. I generated it from Artisan session:table
I did just a refresh on the website.
| id | user_id | ip_address | user_agent | payload | last_activity | | bf4QOHxQAMvrTgGw0PfidIKmHd0hRrAt86FPVYWz | NULL | 2a02:8109:a40:2f20:403d:806a:5818:dbf3 | Mozilla/5.0... | ZXlKcGRpSTZJblV3UkhoY... | 1501147035|
| I0sg8K8zvSQS1a1vN2OOTYnKVnsVJQP3kv4ZxtqT | NULL | 2a02:8109:a40:2f20:403d:806a:5818:dbf3 | Mozilla/5.0... | ZXlKcGRpSTZJbE5WYkVOT... | 1501146839 |