0

Using php session in laravel 5 seems impossible to me. But there is no limit to knowledge.

I got a project from somebody in which php session was used in a laravel project. The project is so huge that converting the php sessions to laravel session is a huge task.

But it seems that the php session supports to work on localhost i.e. wamp and the project seems bug free. But deploying on the server its a mess. The server is a linux server. i tried to replicate the setttings to wamp. But can't get it working.

Is there any minor chance of making the application working without going through the whole project.

2
  • 1
    A global search for $_SESSION should not be too hard Commented Jul 15, 2016 at 11:53
  • To make it clear; you are using the Laravel Session::get/put/push/has...? Do you have an .env-file with APP_KEY? Commented Jul 15, 2016 at 13:13

1 Answer 1

2

Got a fix to it.

The solution was Since the project was to large to change the whole code so i added a small piece of code in the AppServiceProvider

<?php

namespace App\Providers;
session_start();
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
     public function boot()
     {
         $this->composer();
     }

     /**
      * Register any application services.
      *
      * @return void
      */
      public function register()
      {

      }

      public function composer(){
          view()->share($_SESSION);
      }
}

Which defined as a variable in the whole Laravel project as well as session variables to where ever required. Even though this is not the right way to use session but it helps to fix the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.