• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filter route problem

#1
hi , this is my filter:


Code:
<?php namespace App\Filters;

use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;

class UsersFiltersAuth implements FilterInterface
{
    /**
     * Do whatever processing this filter needs to do.
     * By default it should not return anything during
     * normal execution. However, when an abnormal state
     * is found, it should return an instance of
     * CodeIgniter\HTTP\Response. If it does, script
     * execution will end and that Response will be
     * sent back to the client, allowing for error pages,
     * redirects, etc.
     *
     * @param \CodeIgniter\HTTP\RequestInterface $request
     * @param array|null                         $params
     *
     * @return mixed
     */
    public function before(RequestInterface $request, $params = null)
    {
        // if no user is logged in then send them to the login form
        if (!session()->get('user_id'))
        {           
            session()->set('redirect_url', current_url());
           
            return redirect()->to( base_url().'/user/login');
        }
    }

    //--------------------------------------------------------------------

    /**
     * Allows After filters to inspect and modify the response
     * object as needed. This method does not allow any way
     * to stop execution of other after filters, short of
     * throwing an Exception or Error.
     *
     * @param \CodeIgniter\HTTP\RequestInterface  $request
     * @param \CodeIgniter\HTTP\ResponseInterface $response
     * @param array|null                          $arguments
     *
     * @return void
     */
    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
    {

    }

    //--------------------------------------------------------------------

}   // End of YourFilterName Class.

/**
* -----------------------------------------------------------------------
* Filename: YourFilterName.php
* Location: ./app/Filters/YourFilterName.php
* -----------------------------------------------------------------------
*/


And this is my route :


Code:
$routes->group('user_Isee', ['filter' => 'usersFiltersAuth'], function($routes) {
    $routes->match(['get','post'],'isee_anno_presente', 'User_Isee::isee_anno_presente');
    $routes->add('modifica_record/(:num)', 'User_Isee::modifica_record/$1');
});


Inside my controller i have this if :

Code:
        if(!$isee_model->oggetto_di_user($_SESSION['user_id'],$id)) {

            return redirect()->to( base_url().'/user/');
            die();
        }


Why when the session die have  i  error exception undefined index user_id ?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.