Home › Toolset Professional Support › [Resolved] Logging in/ logging out resets the language cookie that Ajax filters need (?)
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Tagged: Views plugin
I need to re-open this thread:
https://toolset.com/forums/topic/discovered-a-bug-in-your-views-plugin-pagination-code-when-used-with-wpml/
I thought we solved the problem.
Shane said "Go to WPML -> Language and ensure that this setting is checked. "
Yes. That DOES work BUT....
If I log into the dashboard then log out again, it's as if the process of logging out resets (or deletes) the cookie as the pagination now goes looking for the DEFAULT language posts.
i.e. the original problem comes back!
To solve this, I can go to the Chrome Browser -> More Tools -> Developer Tools -> Application -> Clear Storage ... click on the CLEAR SITE DATA button.
Now the Views slider will work properly again (until of course, the next time I log into the back end then the problem just repeats).
I'm not sure if this should be categorized as a ToolSet issue or a WPML issue but since you guys are the same company I trust that you can work together to figure this out.
Hi,
I tried to reproduce the issue on a local installation but I didn’t get results.
My process:
- installed and configured WPML (plus String Translation, Translation management and Media) with 2 languages
- activated the Ajax cookie option in WPML -> Languages
- installed and activated Toolset Types, Views and Maps plugin
- logged out/logged in
Please let me know if I’m missing some steps.
This could be a caching problem or a compatibility issue.
I don’t see any specific caching plugin on your site, but your server could have a caching option. Could you check it?
I’d also ask you to do this test:
- backup your site
- disable all your plugins except Toolset and WPML ones
- check if the issue still exists
if not, try to enable your plugins one by one and check each time if the issue exists
If the issue exists even with all plugins disabled, I’d like to ask you for site credentials.
Please watch.
hidden link
Can you please provide a secure form page so that I can provide Admin login credentials?
I've tried this with:
a) All plugins except WPML & ToolSet disabled
b) On TwentySeventeen Theme
I've confirmed:
c) No server caching
Problem exists in:
d) Google Chrome AND Firefox
The ONLY thing which fixes the issue is to go to Developer Tools and manually clear cookies.
Hi,
after reviewing your video, I managed to reproduce the issue.
I’m not sure if Views or WPML cause the problem, but I escalated the ticket to our 2nd tier so we’ll try to find a solution as soon as possible.
I’ll keep you updated.
Hi,
supporters can't reproduce the issue. I tried again on a new local copy and I can't neither.
Could you send me a Duplicator package with a copy of your site so we can further test it? I'll enable a private reply.
Hi,
I tested your site's copy but even logging out and login the Ajax filter was still active.
However, I could see the issue when you are logged out so I'll ask our 2nd tiers again.
Hi. Just checking if you have a status update on this issue?
Hi,
we are still working on it. I'll update you as soon as I have news.
Hi,
Can you try the following to fix your issue:
--go to WPML -> Languages -> Language filtering for AJAX operations
--select ( Store a language cookie to support language filtering for AJAX )
This fixed the issue on my local copy of your website. I hope that this fixes your issue on your website.
Thanks.
NO.
This setting was/is already applied on my site.
hidden link
It fixes the issue WHEN I AM LOGGED IN or if I have NEVER LOGGED IN.
But if I LOG OUT, the problem occurs.
Same problem on a "minimal case" test site.
hidden link
hidden link
If you like, I can provide Admin login so you can check for yourself.
[I need a secure form]
fyi I HAVE ALSO CHANGED the Salt Keys on my main site, hoping that if I invalidate ALL existing cookies that might work.
It DIDN'T.
Please check with Laura.
SHE was able to replicate the issue with the copy I provided to her.
The provided copy would have the SAME settings as my working copy
i.e. I am SURE that the "language filtering for ajax" box is checked on her version as well.
Has there been any progress with this ticket?
It needs to be sorted out.
fyi after not checking the above links for a few days, the problem disappears.
I suspect because whatever cookies it is using are EXPIRED.
Of course, if I log in / log out, the problem re-occurs.
Hi,
our developers found a workaround. I tested it on your site copy and it's working for me.
Can you try it too and see if it fixes the issue? Please do a backup of your site first, as it involves changing WPML plugin files.
Open wp-content/plugins/sitepress-multilingual-cms/inc/request-handling/wpml-backend-request.class.php and search line 43 the function get_ajax_request_lang.
Replace the code with this:
private function get_ajax_request_lang() { $al = $this->active_languages; $lang = isset( $_POST['lang'] ) && in_array( $_POST['lang'], $al, true ) ? sanitize_text_field( $_POST['lang'] ) : null; $lang = null === $lang && isset( $_SERVER[ 'HTTP_REFERER' ] ) ? $this->url_converter->get_language_from_url( $_SERVER[ 'HTTP_REFERER' ] ) : $lang; $lang = null === $lang ? ( $cookie_lang = $this->get_cookie_lang() ) : $lang; $lang = $lang ? $lang : ( isset( $cookie_lang ) ? $cookie_lang : $this->get_cookie_lang() ); $lang = $lang ? $lang : $this->default_language; return $lang; }
Since this is a change made directly to WPML files, you'll probably need to re-add it if you update. We're talking about merging it in a future version so replacing won't be necessary.
Please let me know if the fix works for you.
Yes it works.
HOWEVER, something important I discovered.
The problems we were having were on a staging directory of the main site hidden link
When we migrated this to the main directory, the problem miraculously disappeared.
Which leads me to wonder, perhaps the staging site was getting confused with a cookie that was existent from the main site?
Either way, for the sanity of anyone developing on a staging site in future, I'd like to request that this be rolled into a future release.
thanks.
Hi,
thanks for the feedback, I'll report it to our developers. However, we tested your package and it wasn't installed on a subdirectory, so I don't think that could be the issue.
Happy to hear the issue is resolved, though!