Support the ongoing development of Laravel.io →
posted 5 years ago

Hi, I have this code in my controller:

public function store(Request $request)
    {
        $user = Auth::user();
        if ($user->can('admin')) {

            $p = Product::create($request->all());

            return redirect('products')->with(['message' => 'Prodotto salvato!', 'alert-class' => 'alert-success']);
        }
        return redirect('/')->with(['message' => 'Non hai i permessi!', 'alert-class' => 'alert-danger', 'user' => $user]);
    }

on my dev machine works like a charm, in production product is saved but thenI get logged out. In my session table I see many rows with my IP but null as user_id (ofc if I log in again, there is also a row with my ID). Any idea what can cause this?

Thanks a lot

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

andrea giorg Joined 13 Sep 2018

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.