Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pmt66 opened this issue Dec 18, 2022 · 2 comments
Open

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

pmt66 opened this issue Dec 18, 2022 · 2 comments

Comments

@pmt66
Copy link

pmt66 commented Dec 18, 2022

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

@jakubmisek
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants