Sometimes you just need to get the file extension from a string. Here are a couple quick solutions to get it in literally 1 line of code. Option #1 Option #2
When displaying and using cookies it is important to validate them especially when they are integral to the functionality of the page. Make sure to check to see if the cookie is set before displaying it.