在Laravel 4.1中使用cookie重定向

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.

查看全部
du155305
du155305
2014/04/05 19:21
  • laravel
  • php
  • cookies
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复