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

JustInCase's avatar

PHP session not working!

Hello! i have deployed a app in my vps but the problem is session data is not being saved nor the flash data, i tried it on shared hosting it was working properly and i tried in localhost i worked , is there any configuration i have to do?

0 likes
24 replies
Niush's avatar

If using file driver you will need to give permission to storage and cache directory.

sudo chmod -R 775 storage
sudo chmod -R 777 bootstrap/cache
JustInCase's avatar

@Sinnbeck Still it didn't work , flashdata is getting nulled , nor user data is saved ,

demo : (vps :not working) crypton.cash/admin/login working ;(Shared hosting) beta.rockfaucet.com/admin/login

both username and password is admin you can try it

Snapey's avatar

does your client receive laravel cookies?

Snapey's avatar

@mrphp if it's apache server then you can have an issue if any characters are echoed out before the cookies are sent

this is most often seen when there are some characters before the opening <?php in one of your files

check through all your files for this, and also make sure you never use the closing php tag ?>

JustInCase's avatar

@Snapey Checked All files , nothing wrong with them , as they are working in shared hosting

Snapey's avatar

@mrphp you need to check, don't care if they work on a different type of host

you can also look closely at the response from the server in the developer network tools. does the response start as expected, eg <html or is there something before it?

JustInCase's avatar

@Snapey nothing comes before

demo : (vps :not working) crypton.cash/admin/login working ;(Shared hosting) beta.rockfaucet.com/admin/login

both username and password is admin you can try it

Niush's avatar

Cookies are not being saved in the Browser. Domain looks like is set to localhost. (domain=localhost;) Check your Network Tab by enabling preserve log.

You should set this env variable and also check App Url variable:

SESSION_DOMAIN=.crypton.cash
JustInCase's avatar

@Snapey Hi !

[2022-07-06 03:54:09] production.ERROR: Target class [session] does not exist. {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [session] does not exist. at /var/www/vhosts/crypton.cash/httpdocs/core/vendor/laravel/framework/src/Illuminate/Container/Container.php:879)

this is the problem i guess

Any way to fix it?

Niush's avatar
Niush
Best Answer
Level 50

@mrphp Did your composer install --optimize-autoloader --no-dev ran successfully?

If it did, try php artisan cache:clear and php artisan optimize.

Snapey's avatar

@mrphp Seems you have a class name in lower case? On case insensitive systems this won't matter, but here I guess it does.

Have you done something with session in one of your service providers?

Please or to participate in this conversation.