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

saadaan's avatar

Purpose of key generation?

Hi,

What is the purpose of key generation for laravel?

php artisan key:generate

I generated a key for one project on server A. Then I moved that whole project to server B by copying the project folder alongwith the code. The key remains the same in ENV file. Is it something bad? Do I have to generate a new key? If yes, would it affect the existing code?

Thanks, Saad

0 likes
3 replies
bugsysha's avatar
bugsysha
Best Answer
Level 61

Is it something bad?

Nope.

Do I have to generate a new key?

Nope, but it is a good practice to change them on every few months.

If yes, would it affect the existing code?

It does not affect the code.

What is the purpose of key generation for laravel?

It is used for encrypting and decrypting cookies.

2 likes

Please or to participate in this conversation.