Debugging patterns for programmers who pull their hair off on “The page submitted is invalid for session” on site..

As a programmer debugging on site pages is always a night mare and the reasons are obvious. We do not get exceptions handled if there is a visual force page error gracefully and the generic site.error message does not show a meaningful message. Makes you think whether salesforce is competing with Microsoft IE on this. But here is one tip which helped me to save time on debugging the crazy error “The page submitted is invalid for session”

This would be a scenario where you were using a command link button to submit a form and i was using an action tag submitting to a controller. I also had a javascript on click and on complete event which was submitting the form.

Buggy code

<apex:commandLink action="{!navAction}" onclick="javascript:disabled=true;" onComplete="javascript:disabled=false;NEXTACTION();"

<apex:actionFunction action="{!navAction}" name="NEXTACTION" />


So the form was giving me the crazy Invalid for session error and I tried so many things to fix this but in vain.
Code fix
<apex:commandLink onclick="javascript:disabled=true;" onComplete="javascript:disabled=false;NEXTACTION();"

<apex:actionFunction action="{!navAction}" name="NEXTACTION" />
//Removed the action tag on the command link.


Here was a simple solution a programmer came up with which solved the problem.

So the solution was
a. removed the action tag on the command link and had the action function call the controller action. So the debugging pattern to learn here is
a. Avoid duplicate calls to the controller action.

So if you get the invalid session error and if you use an action function and a command link or button call to controller, have one call to the controller.
Avoid duplicate method calls to the controller –Duplicate controller action pattern.. I will be writing a series of articles on fixing issues quickly which will save you some hair and Time. Save Time !! Work better..

Please Subscribe

Subscribe to our mailing list to get tips on maximizing your salesforce

We respect your privacy.

Please subscribe

Subscribe to our mailing list and get tips to maximize salesforce to your email inbox.

I am honored to have your subscription. Stay tuned for tips to maximize your salesforce investment

Something went wrong.


Author: buyan47

Hi there! My name is Buyan Thyagarajan. I am a Salesforce consultant specializing in Higher Education, Manufacturing and Marketing Automation. My blogs will help you to maximize your Salesforce CRM investments, prevent problems beforehand and make the right decisions. If you need to talk to me right away, you can email me at or call me at 302-438-4097

Leave a Reply

Your email address will not be published. Required fields are marked *