I am writing a web app using Symfony 1.3. I have a problem with my session variables getting lost after I call an action via jQuery's $.ajax()
call. Things happen in this order:
An action sets the session variable like this:
$this->getUser()->setAttribute('uploaded-files', $uploadedFiles);
Then when the action calls the view component, the resulting HTML page contains the following call:
$.ajax({
type: "POST",
url: '<?php echo url_for("content/merge"); ?>',
cache: false,
success: mergingCompleteCallback
});
I click on the button that triggers the above ajax call. The call executes the corresponding action method, but when I print out the content of the 'uploaded-files' session variable, it's empty.
I also checked to see if the session id stays the same between the call to the page that sets the variable and the page that reads the variable (the ajax call) and the session id hasn't changed. I was searching for hours online and I wasn't able to find a solution.
I had the similar problem, and the issue was that I was using host value for storing cookies with 'www' i.e. www.mydomain.com and I was making Ajax request without 'www'
The solution is use the wildcard like host. Like .mydomain.com as your host to store session cookie on browser end.
Just make sure you are not a victim of this?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With