开发者

How to get client-side dateTime in server-side ASP script?

开发者 https://www.devze.com 2023-01-10 04:12 出处:网络
I need to get the browser user local date and Time on my server side asp vbscript page. The goal is to show a specific message to all connected users that are in conversation at a specific local time

I need to get the browser user local date and Time on my server side asp vbscript page.

The goal is to show a specific message to all connected users that are in conversation at a specific local time in my web chat application.

Is that possible?

One way is to include开发者_运维技巧 the local time on an hidden text field and then pass it through using ajax/javascript but it's not secure because user could change it and find the secret time on server side.


The best I can think of would be to cross-reference Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"] to a time zone offset and then calculate their local time using UTC. The liabilities here are trusting that their local language setting corresponds to their time zone appropriately and that your accuracy doesn't need to be perfect all of the time (multiple time zones per language code).

Alternatively, if you can afford to be lazy in this case (how important is this local time to your app?), you could just write some purposely obscure js code to smuggle the local system's current time as a long int and named something misleading for those hackers interested in spoofing your js.

0

精彩评论

暂无评论...
验证码 换一张
取 消