我正在尝试与ASP.NET和ajax / jquery进行随机聊天。当用户进入聊天室时,我需要一种方法来识别用户并给他一个唯一的ID,我将在其中记录他在我的数据库中的单词。我是否需要使用会话,cookie或其他内容?什么是实现随机聊天的最佳方式?
答案 0 :(得分:4)
<强>会话强>
- Will expire if the user are idle for some time in the chat
- Will be terminated when the browser closes, by the server.
+ Cannot be changed by the user
<强>缓存强>
+ Will not expire
+ Will not be terminated on browser close, so the system can identify the user to be the same the next time
- Can be changed by the user
识别用户的绝对最佳方式是数据库(MySQL / Oracle / MSSQL)和cookie的组合。
答案 1 :(得分:1)
我认为你应该使用session_id