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

PHP 7.3 memcache stored sessions issue #16

Closed
nikolasr200 opened this issue Nov 12, 2019 · 15 comments
Closed

PHP 7.3 memcache stored sessions issue #16

nikolasr200 opened this issue Nov 12, 2019 · 15 comments

Comments

@nikolasr200
Copy link

Hi,

i've upgraded my wamp installation to 7.3 from 7.2 Since upgrading to 7.3 and using vc15/ts/x64 memcache i notice incosinstency in sessions, as if the get lost, or unable to retrieve across requests, but they do seem to appear randomly across some requests! This issue was not present in 7.2
It seems kind of what is described over here #15, but now quite sure, since in my case is session stored values.
Not sure if it is related to this build, or if someone could give a hint on what else could be the cause.

@nono303
Copy link
Owner

nono303 commented Nov 12, 2019

Hi @nikolasr200,
As i said in #15, I can't imagine that this issue is related to the build process.
We'll see what happen on pecl-memcache#58 and if you have a test case file reproducing the issue, I'll launch it on my self-built setup (php 7.3.11 vs16 nts avx x64 & memcached cygwin 1.5.20 x64)

@nono303 nono303 self-assigned this Nov 12, 2019
@nikolasr200
Copy link
Author

Unfortunately i don't have a test file, I m using Yii framework and you can easily notice that after log in you soon find yourself logged out, with session acting like it's been lost. In rare cases, after a couple of refreshes it seems as if it has recovered the session, and logs you back in, only to log you out again, if you continue, browsing / refreshing. As i mentioned in the previous comment, we are currently facing this issue in two different machines, and various different projects that use memcache for session handling.

@nono303
Copy link
Owner

nono303 commented Nov 13, 2019

How do you set memcache as the session handler in PHP ?

@nikolasr200
Copy link
Author

nikolasr200 commented Nov 13, 2019

In my php.ini , typically i use this setup flawlessly, in php5.6 and 7.2

[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211

and on the framework i define cache component in the configuration of the application

        'cache' => array( // cache component
            'class' => 'CMemCache', // class to be used for cache componenet
            'servers' => array(
                array(
                    'host' => 'localhost', // memcache runs locally
                    'port' => 11211, // on 11211 port
                ), 
            ),
        ),

and session component to use cache component

        'session' => array( // session component
            'class' => 'CCacheHttpSession', // class to be used for session component
            'cacheID' => 'cache', // configure session to use cache component described above
            'timeout' => 600, // session duration
            'cookieParams' => [ // cookie parameters
              'lifetime' => 600, // cookie expiration duration
              'secure' => true, 
              'httpOnly' => true,
            ],
        ),

This setup came from a yii1 application but similar setup i have on yii2 application as well.

Yesterday, i was playing around with memcache config, and some times i would manage to have session maintained for little longer, other times shorter period. but all of the times sooner or later i ended up losing session and getting logged out unexpectedly

@nono303
Copy link
Owner

nono303 commented Nov 13, 2019

what are the values of session.save_handler &session.save_pathin php.ini ?

@nikolasr200
Copy link
Author

on my php.ini php 7.2 same on my php 7.3 as well

session.save_handler = files
session.save_path ="c:/wamp64/tmp"

tried also

session.save_handler = memcache
session.save_path ="tcp://127.0.0.1:11211"

with no luck

@nono303
Copy link
Owner

nono303 commented Nov 13, 2019

session.save_handler = memcache was (is?) bugged (see README.md > 2016-05-18)

  • Have you tried as I mentioned (see README.md > 2016-05-18) auto_prepend_file = MemcacheSessionHandlerPrepend.php
  • What is your memcached server version / build?
  • Do you distribute php session over more than one memcached server (local or not)?

... I just ask all of this to understand where is the problem in your setup because I use memcache for php sessions handled with prepend_file and a single local memcached server
I hadn’t ever see any consistency problems since i use it for a while....

@nikolasr200
Copy link
Author

nikolasr200 commented Nov 17, 2019

Hi, sorry for the late reply, yes i tried the MemcacheSessionHandlerPrepend.php but seemed making no difference at all.
Locally, where my problem asides for the time being, there is only one memache server, so there is no issue of distributing session, although the outcome may look like it is.
I really appreciate, you asking all this, trying to help me on the issue that i m facing.
I ll give it a try once again with the MemcacheSessionHandlerPrepend.php

@nikolasr200
Copy link
Author

Just a follow up, my memcached.exe (according to details tab is 1.2.6 Danga Interactive)

@nono303
Copy link
Owner

nono303 commented Nov 18, 2019

Hi,
The strange thing is that with my setup: MemcacheSessionHandlerPrepend.php & https://github.com/nono303/PHP7-memcache-dll & https://github.com/nono303/memcached I never notice inconsistency in PHP sessions.
Without way to try to reproduce it on my setup, i can't know how to help you much...
Try to upgrade memcached first!
To exclude your memcached server you could make a good old-school windump of tcp 11211 recording network for php session and try to look for packet making broken session...

@nono303
Copy link
Owner

nono303 commented Nov 18, 2019

Just a follow up, my memcached.exe (according to details tab is 1.2.6 Danga Interactive)

https://github.com/memcached/memcached/blob/master/ChangeLog 2008-07-29 ^^

@nikolasr200
Copy link
Author

nikolasr200 commented Nov 19, 2019

Tested with https://github.com/nono303/memcached , makes no difference at all.
If it wasn't for a single server to be present but two, i would be almost confident that the servers don't share sessions, but it is just a single one! And randomly serves or doesn't serve the initiallized session.

edit:
I installed wireshark as well in order to monitor connection with memcache, but didn't help much.

@nono303 nono303 removed their assignment Nov 20, 2019
@nikolasr200
Copy link
Author

Opened a thread over wampserver as well http://forum.wampserver.com/read.php?2,157041 but they don’t seem to identify it as a wampserver issue

@nikolasr200
Copy link
Author

Hi, just an update,
i set up aLAMP environment using docker, with PHP 7.3 and memcache, and it seems so far that sessions and memcache storage/caching work like a charm. So the problem lies either on the wamp server side, or on the porting of memcache to windows. I can't be sure which one of too :(

@nono303
Copy link
Owner

nono303 commented Nov 30, 2019

Ok, thanks for the feedback!
Closing the ticket on my side ;)

@nono303 nono303 closed this as completed Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants