0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

postしたデータをsessionに保存して利用する with FuelPHP

Posted at

ただのメモ

formで入力した値をsessionに保存して利用したい時
HTTPのPostからFuelPHPのPostで受け取ると値が消える(そもそも記録されてない説)

#####ダメな例

dataPost
<form action="hoge" method="post">
    <input type="text" name="data">
    <button type="submit">submit</button>
</form>

                   ↓

hoge
data = Input::post('data'); 
Session::set('data', $data);

こうするとhogeの一行目で値が消える
値を保存したい時は、HTTPメソッドかFuelPHPのメソッドかどちらか一方だけを使うと消えない

#####良い例

postForm
<?php
use Fuel\Core\Form;
echo Form::open("hoge");
echo Form::input('data','');
echo Form::button('','send');
echo Form::close();

                   ↓

hoge
<?php
use Fuel\Core\Session;
$data = Input::post('data');
Session::set('data',$data);
echo Session::get('data');

そもそもメソッドが別物だから当たり前

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?