I think it would be much simpler with a server side flag. Alternatively you could check out this thread,