Sometimes there is a need to control when a page is accessed through a link and bookmark it. For instance,
your company sells a product that should only be valid for a certain time, or provides access to a special deal.
Every page then needs to include checks to determine if the item in question is valid or not.
ex.
www.secure-coding.com/ProductDetails.aspx?id=68
So a check needs to be made to the database, requiring an extra hit on what may be an already busy system.
If you have items that expire quite often, here is an alternative:
www.secure-coding.com/ProductDetails.aspx?id=68&expires=12282005
Now this is quite obvious of course on how one can get around that. However, encrypting it becomes:
www.secure-coding.com/ProductDetails.aspx?54754a68666e3839467646496659745a7467574750773d3d
A page can then determine if the access is still valid.
Still yet another usage
www.secure-coding.com/Admin/DeleteItem.aspx?id=68
Two scenarios can occur, if you use the querystring to manage items in a database, its quite easy to select the wrong one in your recent history.
One alternative is when a link is generated to DeleteItem.aspx, generate a timestamp. If you use a common page baseclass, then that baseclass can decrypt the querystring and check for an expiration date. If it has expired, the user can be redirect, etc.
Once again I advocate encrypting the querystring. I love it : )
Yes - this can be attacked, as can just about anything - but provides an extra layer of data protection and a means to timestamp your links.
This is especially useful when users have very old links they bookmark and you want an easy way to check the lengths of time users keep old links, and refer them to new/updated links.