如何使用PHP Seesion保留用户​​数据 [英] how to keep user data using PHP seesion

查看:117
本文介绍了如何使用PHP Seesion保留用户​​数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我正在尝试执行以下操作:
一个简单的登录页面,要求用户输入user/pass.验证用户是否存在于db中,然后将用户名写入会话varm,然后.
将他/她重定向到充当小型企业在线商店的其他页面.

现在发生的事情是,用户可以使用贝宝程序购买商品,该程序将重定向到贝宝快速安全结帐页面(付款页面).

付款完成后,我收到服务器上的侦听器脚本通知,该脚本捕获付款状态(以及其他一些信息.),然后运行另一个过程,将所有相关详细信息写入我的数据库. >
现在,我想做的是使用我在第一阶段中保存的会话变量用户名",并将其添加到我正在写入数据库的数据中.
除了,当我在脚本中运行该cmd时,会话var不保留任何值.

我想我不是在会议上受过教育.这里有人可以给我一个线索吗?

moses

hi all.

im trying to do the following :
a simple login page, asking the user for user/pass . verify that user exist in db and then, write the username to a session varm and then .
redirect him/her to another page that acts a small business online store .

what happens now, is that the user can purchase an item using paypal procedure, that redirects to a quick paypal secure check out page (payment page).

when payment is complete, i get a notification to a listener script on my server, that captures the payment status (and some other stuff....) and then runs another procedure that write all the relevant details to my db .

now, what im trying to do, is use the session var ''username'' i saved in the 1st stage, and add it to the data i''m writing to the db .
except, when i run that cmd in the script, the session var holds no value .

i guess im not that educated on sessions. can anybody here plese give me a clue ?

moses

推荐答案

在php中,您可以使用以下命令启动会话:
In php you start a session using:
SESSION_START();


要存储变量,请使用:


To store a variable you use:


_SESSION [' " 您在此处的值";
_SESSION['var'] = "your value here";


要从另一页甚至同一页中的该变量读取,请使用相同的命令减去等号.
然后最后使用以下方法终止会话:


To read from that variable in another page or even the same page use the same command minus the equals sign forward.
Then finally to terminate the session use:

SESSION_DESTROY();


确保在完成读取数据之前不要终止会话,因为终止会话时,它将擦除值.

-乔丹


Make sure not to terminate the session until your done reading the data because when you terminate the session it wipes the values.

-Jordan


这篇关于如何使用PHP Seesion保留用户​​数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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