php:在会话中保存整个 $_POST 变量 [英] php: Save the entire $_POST variable in the session

查看:63
本文介绍了php:在会话中保存整个 $_POST 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是否有效:

$_SESSION['pictures']['rateAlbum']['_POST'] = $_POST;

我想一次性保存会话中的所有 POST 数据.

I want to save all of the POST data in the session in one shot.

哦,反过来呢:

$_POST = $_SESSION['pictures']['rateAlbum']['_POST'];

推荐答案

是的,您可以...如果您在会话中将 $_POST 保存在 $_SESSION 中,您将拥有与 post 相同的数组...

yes you can... if you save $_POST in $_SESSION in session you'll have the same array as post...

你也可以用另一种方式将一些东西保存到 $_POST..

You can also do the other way and save something to $_POST..

你也可以这样做(或者,使用 $_SESSION):

you can also do that (or, using $_SESSION):

   $_POST = array('field1' => 'val1',
       'field1' => 'val1',
       'field1' => 'val1',
       'fieldn' => 'valn');        
   $_SESSION=$_POST;

   $test="hi";
   $_SESSION['field1']="test";
   echo $$_SESSION['field1']; //this print hi       

PHP真的很灵活,几乎可以让你做任何事情,显然要注意安全问题......

PHP is really flexible and let you do almost everthing, obviously pay attention on security problem...

这篇关于php:在会话中保存整个 $_POST 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆