会议不会在laravel中破坏

时间:2016-10-05 09:31:57

标签: php laravel session session-cookies

我的会话有问题。我没有破坏我的会话。在我的会话中,我把current_url的值放在一起,这样如果我从预订页面注册,我会在注册后重新登录页面。但如果我从主页注册,它也会重定向回预订页面。我的控制器是

var myDatabase = new PouchDB('appData', { skip_setup: true, auto_compaction: true});
myService.addSomething(myDatabase);
myService.getSomething(myDatabase);

请各位帮我解决这个问题

2 个答案:

答案 0 :(得分:0)

您的会话值不会被破坏,因为您在调用flush之前返回了该函数。 更改
 return redirect($current_url); Session::flush();

Session::flush(); return redirect($current_url)

答案 1 :(得分:0)

答案是

public function helpPeopleStore (Request $request) {
        if (Auth::check()) {
            $current_url = Session::get('current_url');
            $user = Auth::user();
            $industry = $request->input('industry');
            if (empty($industry)) {
                Session::flash('error', 'Industry is needed');
                return redirect()->back()->withInput();
            }
            $degrees = $request->input('degrees');
            if (empty($degrees)) {
                Session::flash('error', 'Degree is needed');
                return redirect()->back()->withInput();
            }
            $area_of_experiences = $request->input('area_of_experiences');
            if (empty($area_of_experiences)) {
                Session::flash('error', 'area of experiences is needed');
                return redirect()->back()->withInput();
            }

            $user_industry = UserIndustry::where('user_id', $user->id)->first();
            if (!empty($user_industry)) {
                $user_industry = $user_industry;
            } else {
                $user_industry = new UserIndustry();
            }

            $user_degrees_exists = UserDegree::where('user_id', $user->id)->get();
            if (!empty($user_degrees_exists)) {
                foreach ($user_degrees_exists as $user_degree_exist) {
                    UserDegree::destroy($user_degree_exist->id);
                }
            }

            $user_area_of_experiences_exists = UserAreaOfExperience::where('user_id', $user->id)->get();
            if (!empty($user_area_of_experiences_exists)) {
                foreach ($user_area_of_experiences_exists as $user_area_of_experience_exist) {
                    UserAreaOfExperience::destroy($user_area_of_experience_exist->id);
                }
            }

            $user_industry->user_id = $user->id;
            $user_industry->industry_id = $industry;
            $user_industry->save();

            if (!empty($degrees)) {
                foreach ($degrees as $degree) {
                    $user_degrees = new UserDegree();
                    $user_degrees->user_id = $user->id;
                    $user_degrees->degree_id = $degree;
                    $user_degrees->save();
                }
            }

            if (!empty($area_of_experiences)) {
                foreach ($area_of_experiences as $area_of_experience) {
                    $user_area_of_experiences = new UserAreaOfExperience();
                    $user_area_of_experiences->user_id = $user->id;
                    $user_area_of_experiences->area_of_experience_id = $area_of_experience;
                    $user_area_of_experiences->save();
                }
            }
            return redirect($current_url);
            Session::flush();
        } else {
            return redirect('user/registration');
        }

        Session::flush();
    }