peachpie icon indicating copy to clipboard operation
peachpie copied to clipboard

can not access the session variable if the session is not auto start.

Open pmt66 opened this issue 2 years ago • 2 comments

If the session is not set auto start at:

class Startup
   {
       public void ConfigureServices(IServiceCollection services)
       {
           services.AddPhp(options =>
           {
               //options.Session.AutoStart = true; //<==
           });

Although I call session_start() before access session variable like this:

//php
session_start();
$_SESSION['count']=0; // throw error here

It throw error > System.NullReferenceException: Object reference not set to an instance of an object.

I have not found this error for v1.1.0 ,v1.1.1 but found this error for v1.1.2, v1.1.3 I use net5.0

pmt66 avatar Dec 18 '22 12:12 pmt66

thank you for reporting the issue;

This may happen if there are headers sent before calling session_start(). Isn't there anything in the debug log?

jakubmisek avatar Jan 28 '23 14:01 jakubmisek

also; please check what is the return value of session_start() - it's probably returning false with some additional details in debug output.

jakubmisek avatar Jan 28 '23 14:01 jakubmisek