I am trying to drop a cookie for a specific view, so that a user can only visit that page once. However, what I have now is not redirecting the user away from the view on repeated viewings like I want. Here is what I have:
public function getWelcome() {
// Drop cookies and check for it...
$cookie = Cookie::get('cs_welcome');
if(isset($cookie) && $cookie == 1) {
return Redirect::to('/fans/'.Auth::user()->url_tag);
}
else {
$cookie = Cookie::forever('cs_welcome', 1);
}
return View::make('fans.welcome');
Basically I want them to only see the fans.welcome view once. If it is a repeated visit, I want them to go to /fans/Auth::user()->url_tag. Is there something I'm missing here? Thank you for your help.
IMO I believe that with that approach a user can wipe their navigation cookies and then when they go into their account they we'll se the welcome page again.
To have a real persistence that the user saw the welcome screen I recommend that you save that information in your database and relate that to the user.
Let's say $user->sawWelcomePage = true
You should use something like this:
1. Register the user
2. Login the user automatically after creating the account
3. After login redirect to welcome page
Also, if you don't want to log in a user automatically you may skip it.
In both cases, keep a flag, any field in users
table, for example: verified
and by default keep it NULL
once the use logs in then update the field with 1
or any truthy value so you may check if that field is NULL
then the user should be in the welcome
page otherwise don't let the user go to that page.