vendredi 16 mars 2018

Laravel - Distinguish session by user_ID

I have a project where a logged in user can fill in some data. This data will then be stored in a session called "Main_settings". The way I do that is by doing this in my controller:

private $predefinedArray = ['user_id', 'city', 'postal_code', 'street_name',
                            'house_number', 'store_name', 'store_tel',
                            'store_hoo', 'vat_number'];

public function store(Request $request)
{
    foreach($this->predefinedArray as $value) {
        $request->session()->put('main_settings.' . $value, $request->input($value));
    }

   return redirect('themes');
}

I call the session variables by doing this in my view:

If the user returns, His information will still be there, That's not the issue. The problem is, if John Doe logs in and starts filling in the form and then logs out. And Jane Doe logs in, The information that John Doe filled in will be displayed, While Jane Doe didn't even fill anything in yet.

Somehow I need to distinguish a session by a user ID so I can call the session of the logged in User in the view. How can I accomplish this?

The user_id is being sent WITH the form.

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire