2017-04-25 13:04 阅读 65


I'm new to Laravel 5.2 . I have been trying to create a login Page using Session and i wanted to redirect to another page when user login is successfull ...I validate users in Controller create Session and Redirect to a Success Page View but its not returning ...i tried to solve it but i am unable to do so ...the Controller is not returning the View success page ..am i doing it correctly or im missing something

<form id="loginForm">
  <div class="container">
    <input type="text" placeholder="Enter Username" name="username" id="username" required>

    <input type="password" placeholder="Enter Password" name="password" id="password" required>

    <button type="button" id="loginButton">Login</button>
    <input type="checkbox" checked="checked"> Remember me

  <div class="container" style="background-color:#f1f1f1">
    <button type="button" class="cancelbtn">Cancel</button>
    <span class="psw">Forgot <a href="#">password?</a></span>

<script type="text/javascript">
            var formData = new FormData($('#loginForm')[0]);

              url : SERVER_NAME+"/api/userLogin",
              type :"POST",
              data :formData,
              processData: false,
              contentType: false,
              dataType :"json",
              beforeSend: function(){

              success : function(response)

                //return false;

                      // window.location.href = 'home';







MY Controller

 public function userLogin(Request $request)
    $input = $request->all();
    //return $input;
    //return $userName;
    $results = wowza::authenticate($userName,$password); 
    if (sizeof($results)>0){

         if($results[0]->email==$userName && $results[0]->password == $password)
                Session::set('variableName', $userName);

                return \View::make('user.home')->with('results',$results);
                // return response()->json($results);

    return sizeof($results);


My Success Page


My Route

    Route::get('/', function () {
    return view('user.login');

Route::get('home', function () {
    return view('user.home');
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • duanliu6083 duanliu6083 2017-04-26 10:19

    You can change at auth controller as protected $redirectTo = '/dashboard'; or at route as Route::get('dashboard', function () { return redirect('your-path'); }); `

    点赞 评论 复制链接分享
  • douweng7083 douweng7083 2017-04-26 11:06

    Your page is not redirecting because you are loading the view file in your controller. Instead of this code:

    return \View::make('user.home')->with('results',$results);

    You should use redirect('home') method.

    Let me know if that does not work.

    点赞 评论 复制链接分享