I'm building a website which allows the user to drag elements on to the screen using JavaScript and jQuery. I would like to store these elements inside a database, and then draw them back on to the screen when they visit the website again.
Each element will need a unique id, this will be used when performing a few functions such as addComment(id), editElement(id).
An id count is going to be incremented every time an element is added, and this id count will be assigned to the element which has been created e.g.
What would be a secure method of persistently keeping track of this id count? it needs to be used client and server side.
I'm not sure why this is being down voted, it's a pretty clear question.
Solution: I'm going to store the element id's and the total number of elements in a database, each time an element is created an ajax call will be used to assign the id to that element (which will be the element type concatenated with the number of previously created elements) and then store it in the database.
If you are adding the component to a database then I'd use the identity from the database as the ID (with some kind of prefix, i.e. "component1", "component2", etc). That way your are sure that the value is unique.