Archive for March 30th, 2010
ASP.net membership log times incorrect in the database
A colleague of mine is developing an access controlled solution which prevents users logging in with the same credentials from mutliple locations, using ASP.net membership. For this he checks session expiry times against the last activity date in the database to see if the user has left the site allowing the session to expire- but he noticed today the code had stopped working.
The clocks went forward an hour in the UK on Sunday just gone as we go into British Summer Time (BST) instead of GMT which turned out to be the problem. ASP.net membership logs all times in the database using UTC time, matches GMT- the moment we moved into BST we came an hour out of sync! So he had to convert the code to change our local GMT time to UTC before running any comparisons. Sql server actually has a function to return the current UTC date/time;
GETUTCDATE()