php - SlimFramework Redirect Problems -
i'm trying manage login page redirect home page if still logged:
$app->get("/",function() use ($app){ if(!isset($_session['group_id'])){ view::login(); // show login page }else{ $app->redirect('home/'.$_session['group_id']); // go home -> works! } }); $app->get("/home/:group_id",function($group_id) use ($app){ if(isset($_session['group_id'])){ if($_session['group_id'] == $group_id){ view::home(); }else{ $app->redirect('home/'.$_session['group_id']); //-> doesn't work! goes mydomain/home... , not mydomain/mypath/home... } }else{ $app->redirect('/'); // doesn't work! goes root path of webserver } });
comments in code talks problem. can me? :)
i solved in way:
$app->get("/",function() use ($app){ if(!isset($_session['group_id'])){ view::login(); // show login page }else{ $app->redirect('home/'.$_session['group_id']); // go home -> works! } }); $app->get("/home/:group_id",function($group_id) use ($app){ if(isset($_session['group_id'])){ if($_session['group_id'] == $group_id){ view::home(); }else{ $app->redirect('../'); } }else{ $app->redirect('../'); } });
Comments
Post a Comment