Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Session::set() in Ajax file not available after refresh
  • I have a bit of JavaScript for a login that pops up. User fills out form, hits submit, Ajax sends data and validates it then if successful the JavaScript refreshes the page. During the validation, if all went well I wanted to originally set some flash data so that I could show a "You have been logged in" message on the next page load. I couldn't get it to work, so I thought I'll just use a normal session. Still it wouldn't work. The session array was empty. Debugging it a bit I found that after I've set the session in the Ajax file the session array contains the set session. But then on the next page load the session array is empty. I read the concurrency information in the docs but it didn't really solve anything. I'm still having issues with it. For now I've switched to setting a Cookie that I grab on the next page load if it's set, and then delete it after the message has been shown. Ideally I'd like to use Sessions, but can't seem to get past this problem. Any help is much appreciated.
  • Set the log threshold to L_ERROR or higher, and check the logfiles. If there is a session concurrency issue, it will be logged. Which session driver are you using?
  • Sorry for the delayed reply WanWizard.
    I'm using the Cookie driver and looking at the log file there is no concurrency issues being logged. Perhaps a change of driver then?
  • Does that happen with every browser? I know for example that IE stops header processing when it detects a redirect, sometimes causing your session cookie to disappear. If you use server side storage, you will have the same issue, but you won't lose the data, and providing you don't have a session id rotation at that same moment, the new page would be able to retrieve the session and the flash variables.
  • Sorry to be a bother WanWizard. I believe I've fixed the problem. It turned out in an after() method I was checking for the flash data so that was removing it's untouched state and resulting in it being removed. All seems to be working okay now. Thanks for the replies though.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion