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

Session cannot be saved #958

Closed
jinmarcus opened this issue Mar 6, 2018 · 12 comments
Closed

Session cannot be saved #958

jinmarcus opened this issue Mar 6, 2018 · 12 comments

Comments

@jinmarcus
Copy link

jinmarcus commented Mar 6, 2018

Latest version
Session cannot be saved

session()->set('test', 123);

// The result is empty
echo session()->get('test');

@InsiteFX
Copy link
Contributor

InsiteFX commented Mar 6, 2018

`$session->set('some_name', 'some_value');

Your calling it wrong...

@lonnieezell
Copy link
Member

lonnieezell commented Mar 6, 2018

Nothing should have changed with the sessions recently. You should know it’s impossible for me to debug without more information up front.

  • What environment are you running under?
  • what session driver are you using?
  • what does your configuration look like?

And last but most definitely not least - what have you done to debug it yourself and show that it’s an actual bug and not just a misconfiguration?

@InsiteFX
Copy link
Contributor

InsiteFX commented Mar 6, 2018

Lonnie,

Can we call it like that with the () or is that the helper way?

@lonnieezell
Copy link
Member

Yes, it can be called that way. It's in the Common.php file, I believe where we provide a few helper methods for things like sesison, request, and response.

@InsiteFX
Copy link
Contributor

InsiteFX commented Mar 6, 2018

Thank you for clarifying that for me.

@jinmarcus
Copy link
Author

jinmarcus commented Mar 7, 2018

@lonnieezell
windows7 and centos7.0
php7.0 and php7.1
redis session

All wrong

@InsiteFX
Copy link
Contributor

InsiteFX commented Mar 7, 2018

I'm on Windows 10 Pro I'll check it out today.

@InsiteFX
Copy link
Contributor

InsiteFX commented Mar 7, 2018

Lonnie,

I just tested this on my Windows 10 Pro setting the session in the home controller and echoing it out in the welcome_message view and it all worked fine here.
//session started in BaseController Home - session()->set('some_name', 'some_value'); welcome_message - session()->get('some_name');

Windows 10 Pro 64-bit

@InsiteFX
Copy link
Contributor

InsiteFX commented Mar 7, 2018

Windows 10 Pro Apache and php 7.2.3
file sessions

public $sessionDriver            = 'CodeIgniter\Session\Handlers\FileHandler';
public $sessionCookieName        = 'fx_session_';
public $sessionExpiration        = 7200;
public $sessionSavePath          = WRITEPATH.'temp/'; //null;
public $sessionMatchIP           = false;
public $sessionTimeToUpdate      = 300;
public $sessionRegenerateDestroy = false;

@lonnieezell
Copy link
Member

@InsiteFX thanks for testing.

@jinmarcus Can you verify your configuration works with, say the cache library using a Redis driver? At this point I can't confirm whether or not it's your system configuration (which is what I'm leaning toward at the moment) or an actual bug. and I know that Redis can be somewhat tricky to configure properly. Please check the docs, maybe head over to the phpredis page that's linked in the docs and do some experiments with the caching to see if you can narrow things down.

@JakeAi
Copy link
Contributor

JakeAi commented Mar 8, 2018

@lonnieezell A few weeks ago I was using Redis and it was working fine on Windows 10 Pro and 2 Instances of Server 2012.

@zahorniak
Copy link

zahorniak commented Mar 15, 2018

I use DatabaseHandler and every time get 'new data' with this code. Data in DB write and read correct. But something get wrong..

session()->start();
if (session('logged_in') == 'true') {
	print_r(session()->get());
} else {
	session()->set(array(
		'logged_in' => 'true',
	));
	print_r('new data');
}

image

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

5 participants