2

codeigniter ブラケットを使用したフォームがあります

echo form_open('signup');

echo form_close();

送信すると、次のエラーが表示されます

An Error Was Encountered

The action you have requested is not allowed.

ではありません alwaysが、しばしば...

非表示の入力フィールドがフォーム内に存在する場合でも:

<div style="display:none">
<input type="hidden" value="token name is here" name="csrf_token_name">
</div>

これは同様のフォーム(サインイン)でも発生します

編集: フォーム経由で生成された html

<form accept-charset="utf-8" method="post" action="http://www.example.com/signup">
<div style="display:none">
<input type="hidden" value="93565fb5855d31af3d46bd655b11a4a6" name="csrf_token_name">
</div>
<input id="username" type="text" placeholder="Username" maxlength="20" value="" name="username">
<input id="email" type="text" placeholder="Email" value="" name="email">
<input id="password" type="password" placeholder="Password" value="" name="password">
<input id="submit" type="submit" value="Sign up" name="submit">
</form>
4

4 に答える 4

4

それは間違っている。

これを試して

    <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash();?>" />

値は、csrf トークンに対して codeigniter が計算するものでなければなりません。

またはフォームヘルパーを使用すると、codeigniter がこの隠しフィールドを自動的に追加します。

于 2012-04-23T06:40:05.240 に答える
0

私の場合、'csrf_expire' 変数を増やしました - トークンの有効期限が切れる秒数です。

$config['csrf_expire'] = 7200; から。$config['csrf_expire'] = 28800; に

于 2016-08-26T11:51:43.820 に答える