简体   繁体   English

Flash / PHP游戏-会话管理/用户标识

[英]flash/php game - session management/user identification

I have a flash game that requires the user to login. 我有一个Flash游戏,要求用户登录。 The login system is implemented in flash and sends requests to a php backend that checks if the login information is correct. 登录系统在Flash中实现,并将请求发送到php后端,以检查登录信息是否正确。

I have an idea to return a unique, randomly generated sessionID value whenever a user logs in. Whenever the client sends a request to the server, it will send this sessionID as an identifier. 我有一个想法,每当用户登录时,返回一个唯一的,随机生成的sessionID值。每当客户端向服务器发送请求时,它将发送该sessionID作为标识符。 For example, if I assign a user the sessionID '123456', then If the server receives a request 'user:123456, action: bought item X` I will know which user made the request and can update the database accordingly. 例如,如果我为用户分配了sessionID'123456',则如果服务器收到请求'user:123456,操作:购买的商品X`,我将知道哪个用户提出了请求,并可以相应地更新数据库。

When a user logs on again, a different session ID will be generated each time. 当用户再次登录时,每次都会生成一个不同的会话ID。

I'm wondering if this is a good approach? 我想知道这是否是个好方法? It would mean everytime a request is received, I would have to search through the user table until I find a match on sessionID. 这意味着每次收到请求时,我都必须在用户表中进行搜索,直到找到sessionID上的匹配项。 Should I be using php's inbuilt session management? 我应该使用php的内置会话管理吗?

Anyone can send server a request 'user:123456, action: bought item X` . 任何人都可以向服务器发送请求'user:123456,操作:购买的商品X`。 That's unsecure. 那是不安全的。 Use PHP native sessions. 使用PHP本机会话。

See this Setting PHP session variables using Flash Actionscript 请参见使用Flash Actionscript设置PHP会话变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM