Do not tell me how to properly implement. To determine the city by IP, I use the following package "scriptixru / sypexgeo": "0.2.*@dev". I check it in view (that is, the window “Your city N?” pops up on js if yes I write in cookies, if not - the sample page opens). Further, if the user is authorized - you need to write to the database and make a selection of the selected city, if not - just make a selection of cookies. Tell me how to implement it correctly - using Middleware.

  • In the session, store the city of the user (for an unauthorized, for an authorized, take the city from the base). If there is no city in the session, then using the software, redirect the user to the city selection page, if there is a city, then your software simply skips the request further, doing nothing. You yourself answered your question. - SlyDeath
  • Thanks for the answer . Tried to save cookies with js - setCookie. - Konstantin Maslov

0