I want to do session handling in myproject i have a login page as well as register page so what i have done yet i have store all the values in the session data and i have destroy that value at the time of logout using flush function of laravel but i have to check in the middile page of register that if session is exists or not if session data is null user automatically redirect on login page.For this i have made a helpers.php file in my controller which checks whether session data is empty or not if not then it will redirect on login page and i have include that will in all controller.But it is showing error.Below is my code and error which i have facing.
Test_laravel\app\Http\Controllers\CrudController.php
<?php
namespace App\Http\Controllers;
//request class is use for take form input
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
//for database
use DB;
//to use models
use App\Crud;
class CrudController extends Controller {
public function index() {
return view('register');
}
}
Test_laravel\app\helpers.php
<?php
// My common functions
$is_login=session()->get('data');
// var_dump($is_login);die;
if(empty($is_login))
{
return view('login');
}
?>
But it is showing below error please help me to resolve this error i am beginner in laravel framework.How can i achieve session handling in laravel is some user logout from the project and they should not be able to reopen that register page,if they try to open that page then it should redirect on login page of my project.
Error Fatal error: Call to a member function make() on a non-object in D:\php\wamp\www\Test_laravel\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php on line 105
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire