edstevo's avatar

Change Laravel App_Key

Hi,

I'm trying to create two apps across two servers and so I need to share the APP_KEY.

The problem is I'm mid development on both apps, and I changed the APP_KEY on one to match the other, and now I'm getting a Token Mismatch Error.

I've cleared all sessions from the DB, and clear my browsers history, re-migrated the DB and removed all remember_tokens.

How do you go about changing the APP_KEY?

Thanks,

Ed

0 likes
6 replies
bestmomo's avatar

If you change APP_KEY in .env file that must work.

edstevo's avatar

Thanks for the suggestions, but changing the key is what caused the issue.

I've changed the key to match that of the second app, and now the first app is showing Token Mismatch Errors.

Kryptonit3's avatar

try opening your site up in an incognito window and see if the problem persists. If not, then is is a browser cookie/caching issue.

Chrome: CTRL + SHIFT + N

FF & IE: CTRL + SHIFT + P

edstevo's avatar

Hi incognito did not solve the problem either. I even tried with a fresh install of Laravel and changed the key before doing anything!

edstevo's avatar
edstevo
OP
Best Answer
Level 1

So I found the problem.....

I read somewhere that in order to share cookies across sub-domains, you must prefix the cookie domain with *. I.e. *.app.com.

This was in fact invalidating the cookies, which meant they weren't being set in the browser.

I'm now desperately trying to find this thread to warn others!

Thanks for you time.

Please or to participate in this conversation.