开发者

Storing POST data in SESSION

I'm creating a multi-step survey and want to store the data 开发者_运维百科in $_SESSION before writing everything to a database. Is there anything I should be doing to the data before storing it there from a security perspective?


Assuming you're on the regular file-based sessions, then you don't have much to worry about from an injection vulnerability view. PHP will take care of the mechanics of read/writing the session file, using serialize() and the like. Stuff whatever you want into $_SESSION and it'll magically be there on the next page invocation.

However, from the broader security perspective, anything that goes into the session file IS readable by anything else running under the same web server instance (e.g. the apache user ID). So it's not somewhere you could store sensitive data, let along things like credit cart/cvv numbers.


well, to avoid problems recovering the data, i suggest you to use a name for the session and use an array exclusively for the post data, kinda:

$_SESSION['postData'] = $_POST;


Its fairly safe to throw whatever you want in the session without sanitizing it. You could though, since you're going to anyways, sanitize it before putting it in the session so its ready to go into the database, then you can sleep more soundly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜