A
A
Alexey Budaev2017-08-17 17:36:16
Laravel
Alexey Budaev, 2017-08-17 17:36:16

How to store data for unauthorized user in Laravel?

Hello!
I'm working on a specific project in which I need to save some information about the user even before the user logs in. For example, it could be a city. Case from the head: the user entered the site, the system automatically determined the city and saved it. Accordingly, if she made a mistake, the user can change his city and the system will also remember it.
The thought occurred to me that it is possible to store anonymous users in the database, making email, password and username optional, but this looks like a crutch and I don’t want to do this yet. I'm sure there is a best practice for this.
PS In the process of writing the question, the idea came to implement this through sessions or cookies, but again I'm not sure what I think in the right way.
I will be glad to any advice and solutions.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
roxik, 2017-08-17
@Markus_Kane

Yes that's right. Sessions are used for this. You can also extend the session lifetime in the config/session.php configuration.

K
Konstantin B., 2017-08-17
@Kostik_1993

Cookies need to be stored

M
miki131, 2017-08-17
@miki131

The session is quite suitable for this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question