传递会话变量阿贾克斯称为PHP脚本 [英] Pass Session variable to the ajax called PHP script

查看:86
本文介绍了传递会话变量阿贾克斯称为PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用的会议在我的PHP脚本我想会话变量传递给调用的脚本的PHP。但是,会话变量没有被称为的session_start()函数不能后HTML code使用。我使用的是简单的JavaScript的AJAX。请给我提供了路径。

While using the sessions in my PHP script I wanted to pass the session variable to the PHP called script. But the session variables are not being called as the session_start() function could not be used after the HTML code. I am using the simple Javascript AJAX. Please provide me the path.

推荐答案

我想你需要的是以下内容:

I think what you need is the following:

在你的PHP脚本打开/请求使用Ajax,你必须在第一行加入:

in your php-script you open/request with ajax, you have to add in the first line:

session_start(session_id());

这样,您就可以访问到你调用AJAX请求您存储在会话变量

This way, you have access to the variables you stored in your session where you called the request with ajax

这篇关于传递会话变量阿贾克斯称为PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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