Laravel会议没有坚持下去

时间:2014-07-17 16:21:45

标签: php session authentication laravel-4

我已经用laravel 4.1.30开发了一个应用程序。在我的本地机器上,该应用程序工作正常但是,当我将它部署到共享的cPanel托管它不起作用。当我登录时,它会再次重定向回登录页面。我通过关闭身份验证过滤器测试它,它工作正常。但是使用身份验证过滤器它不起作用。

这是我的route.php

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::get('/',function(){
    return Redirect::to("/login");
});

Route::get("login", array('as' => 'login', function(){
    return View::make("admin.login");
}))->before("guest");

Route::post("login", "AccountController@login");
Route::get("logout", "AccountController@logout");
Route::get("/admin", array('as' => 'admin', 'uses' => "AccountController@admin"))->before("auth");

Route::get("/admission", "AdmissionController@loadTable");
Route::get("/admission/create", "AdmissionController@create");
Route::post("/admission/save", "AdmissionController@save");
Route::get("/admission/edit", "AdmissionController@edit");

Route::get("/category", "CategoryController@loadTable");
Route::get("/category/create", "CategoryController@create");
Route::get("/category/edit", "CategoryController@edit");
Route::post("/category/save", "CategoryController@save");

Route::get("/sells/loadTable", "SellsController@loadTable");
Route::get("/sells/create", "SellsController@create");
Route::post("/sells/save", "SellsController@save");
Route::get("/sells/selection", "SellsController@selection");
Route::get("/sells/pdf", "SellsController@pdf");
Route::get("/sells/view", "SellsController@view");
Route::get("/sells/reportForm", "SellsController@reportForm");
Route::post("/sells/report", "SellsController@report");

Route::get("/product/loadTable", "ProductController@loadTable");
Route::get("/product/create", "ProductController@create");
Route::get("/product/view", "ProductController@view");
Route::post("/product/save", "ProductController@save");
Route::get("/product/inventory", "ProductController@loadInventoryForm");
Route::post("/product/updateInventory", "ProductController@updateInventory");
Route::get("/product/selection", "ProductController@productForSelection");
Route::get("/product/history", "ProductController@history");

Route::get("/package/loadTable", "PackageController@loadTable");
Route::get("/package/create", "PackageController@create");
Route::post("/package/save", "PackageController@save");

Route::controller('user', 'UserController');

Route::get("test", function(){
    $ym = DateTime::createFromFormat('m/d/Y h:i:s', '10/16/2003 00:00:00')->format("y-m-d h:i:s");
    $x = new DateTime("07/01/2014 00:00:00");
    $y = new DateTime("07/01/2014 23:59:59");
    $x = Sell::whereRaw("created_at >= ? and created_at <= ?", array($x, $y))->get();
    return $x;
});

这是filter.php

<?php

/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/

App::before(function($request)
{
    date_default_timezone_set('Asia/Dhaka');

});


App::after(function($request, $response)
{
    //
});

/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/

Route::filter('auth', function()
{
    if (Auth::guest()) {
        return Redirect::guest('login');
    }
});




Route::filter('auth.basic', function()
{
    return Auth::basic();
});

/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/

Route::filter('guest', function()
{
    if (Auth::check()) return Redirect::to('/admin');
});

/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/

Route::filter('csrf', function()
{
    if (Session::token() != Input::get('_token'))
    {
        throw new Illuminate\Session\TokenMismatchException;
    }
});

Route::filter('super_admin', function(){
    if(!Auth::check() || Auth::user()->weight < 5) {
        return array('status' => 'error', 'message' => 'You do not have right permission');
    }
});

Route::filter('admin', function(){
    if(!Auth::check() || Auth::user()->weight < 4) {
        return array('status' => 'error', 'message' => 'You do not have right permission');
    }
});

Route::filter('normal', function(){
    if(!Auth::check() || Auth::user()->weight < 3) {
        return array('status' => 'error', 'message' => 'You do not have right permission');
    }
});

这是我的session.php

<?php

return array(

    /*
    |--------------------------------------------------------------------------
    | Default Session Driver
    |--------------------------------------------------------------------------
    |
    | This option controls the default session "driver" that will be used on
    | requests. By default, we will use the lightweight native driver but
    | you may specify any of the other wonderful drivers provided here.
    |
    | Supported: "file", "cookie", "database", "apc",
    |            "memcached", "redis", "array"
    |
    */

    'driver' => 'file',

    /*
    |--------------------------------------------------------------------------
    | Session Lifetime
    |--------------------------------------------------------------------------
    |
    | Here you may specify the number of minutes that you wish the session
    | to be allowed to remain idle before it expires. If you want them
    | to immediately expire on the browser closing, set that option.
    |
    */

    'lifetime' => 30,

    'expire_on_close' => true,

    /*
    |--------------------------------------------------------------------------
    | Session File Location
    |--------------------------------------------------------------------------
    |
    | When using the native session driver, we need a location where session
    | files may be stored. A default has been set for you but a different
    | location may be specified. This is only needed for file sessions.
    |
    */

    'files' => storage_path().'/sessions',

    /*
    |--------------------------------------------------------------------------
    | Session Database Connection
    |--------------------------------------------------------------------------
    |
    | When using the "database" or "redis" session drivers, you may specify a
    | connection that should be used to manage these sessions. This should
    | correspond to a connection in your database configuration options.
    |
    */

    'connection' => null,

    /*
    |--------------------------------------------------------------------------
    | Session Database Table
    |--------------------------------------------------------------------------
    |
    | When using the "database" session driver, you may specify the table we
    | should use to manage the sessions. Of course, a sensible default is
    | provided for you; however, you are free to change this as needed.
    |
    */

    'table' => 'sessions',

    /*
    |--------------------------------------------------------------------------
    | Session Sweeping Lottery
    |--------------------------------------------------------------------------
    |
    | Some session drivers must manually sweep their storage location to get
    | rid of old sessions from storage. Here are the chances that it will
    | happen on a given request. By default, the odds are 2 out of 100.
    |
    */

    'lottery' => array(2, 100),

    /*
    |--------------------------------------------------------------------------
    | Session Cookie Name
    |--------------------------------------------------------------------------
    |
    | Here you may change the name of the cookie used to identify a session
    | instance by ID. The name specified here will get used every time a
    | new session cookie is created by the framework for every driver.
    |
    */

    'cookie' => 'chcool_session',

    /*
    |--------------------------------------------------------------------------
    | Session Cookie Path
    |--------------------------------------------------------------------------
    |
    | The session cookie path determines the path for which the cookie will
    | be regarded as available. Typically, this will be the root path of
    | your application but you are free to change this when necessary.
    |
    */

    'path' => '/',

    /*
    |--------------------------------------------------------------------------
    | Session Cookie Domain
    |--------------------------------------------------------------------------
    |
    | Here you may change the domain of the cookie used to identify a session
    | in your application. This will determine which domains the cookie is
    | available to in your application. A sensible default has been set.
    |
    */

    'domain' => null,

    /*
    |--------------------------------------------------------------------------
    | HTTPS Only Cookies
    |--------------------------------------------------------------------------
    |
    | By setting this option to true, session cookies will only be sent back
    | to the server if the browser has a HTTPS connection. This will keep
    | the cookie from being sent to you if it can not be done securely.
    |
    */

    'secure' => false,

);

1 个答案:

答案 0 :(得分:0)

可能是这样的: dump App :: environment();如果它说xvz,那么检查你的app / config中是否有xyz目录。那里的文件具有优先权。