I've never found need to temporarily hold something like this in session, and it can be confusing if the user has a tendency to duplicate tabs (gets the same session).
If a request like posts/5/comments/createcomes in, then the main thing to check is that the user is allowed to create a comment on post 5, not that it was 5 that was sent to the form.