php-mongo-session icon indicating copy to clipboard operation
php-mongo-session copied to clipboard

Added support for apps using namespaces

Open PhilLehmann opened this issue 9 years ago • 3 comments

For coherency, I had to place the class into a namespace (not included in this fix of course).

Prior to the fix, class_exists('MongoClient') would fail, as MongoClient was not in the same namespace, hence the change to class_exists('\MongoClient').

Two issues were fixed regarding session timeout:

  • cookie was not set
  • session.gc_maxlifetime was not set using the right option

Thanks for this awesome class!

PhilLehmann avatar Mar 15 '15 08:03 PhilLehmann

Hi @philrykoff thank you for your contribution.

Regarding the namespaces, I'm still maintaining PHP 5.2.17+ support at this moment so the code needs to make this check carefully since \MongoClient isn't a valid classname prior to 5.2.17.

However, unless a namespace is declared, there should be no issues with classes not used with the full namespace:

php > class_exists('MongoClient');
php > var_dump(class_exists('MongoClient'));
bool(true)
php > var_dump(phpversion());
string(5) "5.6.3"
php > 

I would ask that you verify that you have the mongo extension loaded and running.

I would also ask that you split up your PR and separate the cookie/session settings and I will merge that.

nicktacular avatar Mar 16 '15 11:03 nicktacular

Hey @nicktacular - done!

PhilLehmann avatar Mar 17 '15 19:03 PhilLehmann

@nicktacular, merge please

fedorovvldmr avatar Aug 17 '17 21:08 fedorovvldmr