如何从Ajax调用传递php会话变量 [英] How Do I pass php Session Variable From Ajax Call

查看:70
本文介绍了如何从Ajax调用传递php会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个login.php页面,用于通过Ajax调用验证用户登录。当ajax验证成功时,它会设置会话。当我从登录页面导航时,我想将会话变量传递到下一页。

请参阅下面的jquery代码:



 $ .ajax({
类型:POST,
url:ajaxLogin.php,
数据:dataString,
cache:false,
beforeSend:function(){$(#login)。val('Connecting ...');},
success:function(data){
if(data)
{
$(body)。load(nextPage.php).hide()。fadeIn(1500).delay(6000);





nextPage.php应该包含从ajaxLogin.php成功验证的会话集,但它没有。



请帮忙。

谢谢

解决方案

.ajax({
type:POST,
url:ajaxLogin.php ,
data:dataString,
cache:false,
beforeSend:function(){


(#login)。val('Connecting ...');},
success:function(data){
if(data)
{


(body)。load(nextPage.php).hide()。fadeIn(1500).delay(6000);





nextPage.php应该包含从ajaxLogin.php成功验证的会话集,但它没有。



请帮忙。

谢谢


I have a login.php page that validates user login with a Ajax call. When the ajax validation is successful, it sets a session. I want to pass the session variable on to next page as I navigate from the login page.
See jquery code below:

$.ajax({
            type: "POST",
            url: "ajaxLogin.php",
            data: dataString,
            cache: false,
            beforeSend: function(){ $("#login").val('Connecting...');},
            success: function(data){
            if(data)
            {
            $("body").load(nextPage.php).hide().fadeIn(1500).delay(6000);



The "nextPage.php" should contain the session set on successful validation from the ajaxLogin.php but, it does not.

Please help.
Thanks

解决方案

.ajax({ type: "POST", url: "ajaxLogin.php", data: dataString, cache: false, beforeSend: function(){


("#login").val('Connecting...');}, success: function(data){ if(data) {


("body").load(nextPage.php).hide().fadeIn(1500).delay(6000);



The "nextPage.php" should contain the session set on successful validation from the ajaxLogin.php but, it does not.

Please help.
Thanks


这篇关于如何从Ajax调用传递php会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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