session->set not save data #16632
Replies: 6 comments 1 reply
-
Try changing the line: if($this->session->get("filters")){ to: if($this->session->has("filters")){ Using "has" is the correct way to test for a session variable and it will return false if "filters" is not present in the session data. This is how I define my sesison DI in index.php for Phalcon 5:
Hope this helps a little. |
Beta Was this translation helpful? Give feedback.
-
Thanks, but still not works . I dont know if is needed to use "session_start()" method in php to make phalcon 5 sessions works. Thanks |
Beta Was this translation helpful? Give feedback.
-
Strange. I don't have to do a session_start() call. I check for a session variable and set it in my code right after the DI code block. Now, I will say that I had a client last week report an issue with session data not being set on ONE of the PC's they were using that was running Chrome. I was unable to identify what setting they were using in their browser to cause that issue. They used Firefox on a different PC and it worked fine. I wonder of you are having that issue? Can you test on another PC and with a different browser to see if the session data is being set? |
Beta Was this translation helpful? Give feedback.
-
OK, this is a long shot but worth considering. I have a product that lets users upload and manage product image files for ecommerce marketplace users (Amazon, eBay, Shopify, etc.). I have a customer who was complaining that when they enter a search term into our search bar, that term is being ignored. Now we set that search term in an session variable and, sure enough, that term was not being properly set. It turned out that the customer is using a Chrome extension called Helium 10. We already knew that the Helium 10 plugin interfered with lazy loading of image files, so this was a new aspect to the issues it causes. So is it possible that you have a browser extension loaded that is causing your issue? |
Beta Was this translation helpful? Give feedback.
-
Maybe in some cases the error may be in a plugin, but in my case i debug all the code and i know i receive the correct data in the $session_filter var, but when call set the data is not be written in the session. I can view the content of the session file in server and the data i can see in step before set is not been written in the file. |
Beta Was this translation helpful? Give feedback.
-
If data isn't being saved in your MySQL database updates, that would suggest that either you enable transactions and didn't commit, or there is a larger issue with session handling and something isn't configured correctly at the server level. I guess I'm out of ideas for the moment. |
Beta Was this translation helpful? Give feedback.
-
HEllo!
I have an application in phalcon 5.6 with php8.2. I use session to store data for all session, as all people. But sometimes when call session->set("data","some_data") the new data is not write in session. In my index.php i have the session:
$di->setShared('session', function () { $session = new Manager(); $files = new Stream( [ 'savePath' => '/tmp', ] ); $session->setAdapter($files); $session->start(); });
I have a method in a Controller that save some filter information (filter is an array):
`
public function saveFiltersAction(){
$filters=$this->request->getPost('filters');
`
This method is called from ajax everytime i change an input content, but sometimes it is saving the new data in session, but not always. I have checked the file inside my server and sometimes the values changes. The method returns a 200 and no errors.
I have tried to create a database adapter for save session and it works, but the problem is the same.
I have checked my code but i don´t find why session->set not working
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions