I have a site where people can create posts and submit them (like on Stackoverflow and Facebook).
One thing that the user can do is attach a photo before submitting the post. So as soon as the photo is attached (using AJAX), a new PostID
is created in the backend database table for the post that's being worked on and stored in the user's SESSION
scope e.g. SESSION.LoggedIn.PostID = rsInsertedPost.PostID
.
The same things happens even if a photo isn't attached except that it will create the PostID
on the final submission of the post instead.
The reason I store it in the SESSION scope is because the PostID
that's just been created is used in multiple other areas in the backend application (CFC component in my case). For example, it will insert tags that the user associated with his post into a seperate table dbo.PostTags
like such:
PostID | Tag
44 ColdFusion
44 Programming
44 SQL
After it has finished processing the form submission, it will remove the PostID
from the user's SESSION.
The problem that I am about to encounter is when a user opens up multiple browser windows and decides to start working on multiple posts at the same time. The SESSION's PostID value will keep being overwritten by the newly created one which means that if they decided to go back to a different browser tab and submit their post it would end up affecting the last created Post.
What would be a good way to overcome this issue of keeping a track of PostIDs that people are currently working on per window. Is there some other unique attribute I could store in the SESSION alongside the PostID so that only that one will be affected per browser window thats open?