-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Destroying all sessions when using axios request in VueJs #14694
Comments
Can you check if nginx/php-fpm is having the same extensions loaded as the cmd-line. (get_loaded_extensions() and php -m) Axios is working with Phalcon serve right? |
php -m:
var_dump(get_loaded_extensions()):
Equally.
Yes |
From what I can see now it must be something with your nginx or php-fpm config. Looks like Nginx is not forwarding the session cookie so php-fpm starts a new session. |
@ruudboon For the purity of the experiment, I installed a new ubuntu on 18.04, with default nginx and php-fpm config. http://ph4.sergeymukhin.com nginx config
here is the nginx virtual host.
the problem still remains) |
I also think that nevertheless the problem is somewhere in nginx with fpm, but is it really just me :)) those. it turns out at some point the session is being regenerated. |
Please check, is your client sends correct cookies with request. |
@ruudboon I think that most likely this is an axios issue with passing cookies during a request. |
@andrew-demb cookies are always correct, do not change, in particular PHPSESSID |
I created a simple application on native php, the application repeats the functional of the problem, and there the session is not regenerated, although the request from axios remains the same. https://github.com/sinbadxiii/example-axios-request I'm stuck |
@ruudboon if the session adapter is Phalcon\Session\Adapter\Redis, then everything is ok, if the use Phalcon\Session\Adapter\Stream then the session is regenerated. Can this solve the problem somehow? |
Also check what is your session lifetime |
by default session.gc_maxlifetime = 1440 |
@sinbadxiii Trying to reproduce this but can't reach this server at the moment. Maybe you can ping me on Discord? |
@ruudboon I just destroyed the server the day before yesterday :) But with this I wanted to show that the problem exists on default config.
Ок |
I confirmed this on the webserver of @sinbadxiii Few things I can confirm
Besides that I'm 95% sure it isn't related to Axios. But I do think it is creating the conditions to fail. I think it occurs when 2 requests are handled at the same time. My laptop is currently being serviced so cannot fully reproduce this locally but I'm expecting that the file is being written at the same moment an other request tries to read it. We use file_get_contents to open the session and I'm not sure if it handles advisory locks. Update: Looks like we don't set a file lock when writing. |
file_get_contents doesn't care about file locks. <?php
$file = "test.txt";
//Write file
file_put_contents($file, "Test");
$handle = fopen($file, 'rb');
//Lock exclusive
flock($handle, LOCK_EX);
$contents = file_get_contents($file);
flock($handle, LOCK_UN);
fclose($handle);
print $contents; |
May be helpful reference to PHP implementation of files adapter: https://github.com/php/php-src/blob/master/ext/session/mod_files.c |
@andrew-demb Yes. I'm doing something similar now. ruudboon@6281551#diff-7569882dd2736f23d2142a34913e6d7fR123 |
Hi, I think we have the same problem. In an api Im working on, randomly (after 10s of simultaneous frontend queries after login) the session file get emptied .. @ruudboon do have any idea on the 4.0.3 release date?
|
@Nomadzy We're aiming for Saturday. If you have time. Please clone my branch and rebuild Phalcon to test my fixes. @sinbadxiii can probably test this later when he's back from work. But the sooner we know it's working the better. https://github.com/ruudboon/cphalcon/tree/fix-session-issue-14694 |
@ruudboon I think its fine now. Compiled it and got the '4.0.0-RC.3' .. been using it for ten minutes, so far so good .. I'll test it more tomorrow Thanks a lot |
@Nomadzy then you builded it from the master branch. Please switch branch first after cloning.
|
@ruudboon I suspected that I did something wrong as I lost more sessions. thx again |
@Nomadzy Dropping a pull in that case |
@ruudboon unfortunately the problem remains UPD: I updated zephir to 0.12.16 Thanks very much |
@sinbadxiii Thnx for confirming. Will merge this today and release it in 4.0.3 |
* ruudboon-fix-session-issue-14694: Fixed asset Replaced implementation Missing let Use filepath to build correct path Styling fix [ci-skip] Updated Changelog Updated Changelog Without doing a file exists check we aren't able to detect if extension is set. I would like to make the users responsibility to not add the extension like it's described in the docs. Fixed #14756 Fixed in storage adapter as well Wait for lock is removed Wait for lock is removed Lock files while writing. Fix issue #14694
Fixed in #14759 |
If more than one session, for example, "cart.content" and "compare.content", and then put the values there. Then often refresh the page, soon all sessions are destroyed. The request can be either a POST or GET, there is no difference.
The page uses data retrieval through the Ajax request Vue component, using axios.
Application repository for example:
https://github.com/sinbadxiii/phalcon4-problem-vue-request
Youtube video link:
The problem manifests itself when using the virtual host in Nginx.
If you run the application through a "phalcon serve", then the destruction of the sessions cannot be achieved.
Has anyone encountered such a problem?
The text was updated successfully, but these errors were encountered: