I have a D8 project where the client wants users to select a route they will follow depending on who they are (let's call the two groups Students and Employers), and then the next time they visit show the home page for the appropriate group.
So for example if they click mydomain.com/students, the next time they visit mydomain.com/ it will redirect them to /students
The users will always be anonymous, so not logged in.
I have seen various solutions to this (e.g. the Front module), but they all seem to be dependent either on user role (no use for anon users), a subdomain or browser locale, none of which help us.
What I have in mind is that when visiting one of the target landing pages (e.g. /students) with a Referrer header of the home page, we set a cookie or session variable. Then when the root URL is requested with no or an external Referrer header (so you can still go to the proper homepage via navigation), we check for this and send a redirect if appropriate. The actual paths used could be saved in config.
I'm sure there is a hook I can use somewhere in core to do this, haven't looked into it in much detail yet, but my biggest concern is caching. If the homepage is cached, the hook would never fire and we wouldn't get the redirect, but at the same time I don't want to disable caching on the homepage.
Any experiences/ideas here would be very much appreciated.