updated version with cookies and removed ie 9 support(not working)