实际上,我正在开发 Steam 交易报价功能,但遇到了问题。我已经下载了 Steam 类库并在 Codeigniter 中实现了它。我正在按照 https://github.com/halipso/php-steam-tradeoffers#setupsessionid-cookies 中的设置指南进行操作这个。其实我不知道session id和cookie:
$steam->setup('sessionID', 'cookies');
sessionID
和 cookies
是什么?
我已经阅读了它,但没有得到任何解决方案。我如何在我的代码中获取和实现它?
最佳答案
好吧,如果这是在 Laravel 上,您可以发送 _token
,它们将其称为 csrf_field
。
在 CI 中你可以这样做。 (csrf
生成唯一 session ID)
路径 - application/config/config.php
$config['csrf_protection'] = TRUE;
在登录表单中,你可以添加这个或者在页面初始化中你可以添加这个
$csrf = array(
'name' => $this->security->get_csrf_token_name(),
'hash' => $this->security->get_csrf_hash()
);
<input type="hidden" name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" />
所以在保存的时候你可以把这个添加到 session 中。顺便说一句,这个 token 也可以用于 cookie。
阅读此 Cross-site request forgery (CSRF)
Tokens may be either regenerated on every submission (default) or kept the same throughout the life of the CSRF cookie. The default regeneration of tokens provides stricter security, but may result in usability concerns as other tokens become invalid (back/forward navigation, multiple tabs/windows, asynchronous actions, etc). You may alter this behavior by editing the following config parameter
Source Codeigniter documentation
如果它不在登录页面中,则
最好选择这个false
,(因为这个 token 可能会在每次提交时重新生成(默认))
$config['csrf_regenerate'] = FALSE;
关于php - 我如何发送交易报价,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47196583/