移动浏览器不支持会话变量? [英] Mobile browsers doesn't support session variables?

查看:87
本文介绍了移动浏览器不支持会话变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个浏览器版本的网络应用程序,我有一些存储在cookie中的值。现在我正在制作移动版本,似乎我的cookie无效。
是否可以在移动设备上使用cookies?

I have a browser version of my web app and I have some values stored in cookies. Now I am making a mobile version and it seems that my cookies are not working. Is it possible to use cookies on mobile devices?

我正在尝试执行此代码,我的php给了我一个空值:

I am trying to perform this code and my php is giving me an empty value:

$(document).ready(function() {
    var session_lang= '<?php if(isset($_SESSION['SESS_LANGUAGE']))
                            echo $_SESSION['SESS_LANGUAGE'];?>';
            if (session_lang!='')
            {
                check_and_change(session_lang);   
            }
    });

有没有其他方法可以将数据存储在内部存储器中,以便它可以作为cookie工作?
移动设备是否支持会话变量?我正在查看firebug,我可以看到我可以创建会话变量但是当我想要读它时它是null。
可能有什么问题以及如何解决这个问题?

Is there any other way to store data in internal memory so it can work as cookie? Does mobile devices support session variables? I am looking on the firebug and I can see that I can create session variable but when I want to read it it is null. What could be a problem and how to solve this?

编辑:
我会给你几乎整个代码,这样你就可以看到我是什么做...顺便说一句。此代码在PC浏览器上正常工作。

I will put you almost entire code so you can see what am I doing...btw. this code is working normally on PC browser.

Javascript文件:

Javascript file:

$(document).ready(function() {

    function languageChange()
    {
         var lang = $('#websites1 option:selected').val();

        return lang;
    }


    $('#websites1').change(function(e) {                    

        var lang = languageChange();

        var dataString = 'lang=' + lang;

        $.ajax({

            type: "POST",
            url: "pass_value.php",
            data: dataString,
            dataType: 'json',
            cache: false,
            success: function(response) {

                    check_and_change(response.message);
                 }
        });

        return false;

    });

} );

    function check_and_change(lang)
     {
            switch (lang)
                         { //do something
                          }
    }

然后我上面的第一部分是在我正在寻找的实际php网站上,它正在打开:

Then this first part that I have put above is on the actual php site that I am looking and which is opening:

最后一件事是pass_value.php:

And the last thing is pass_value.php:

<?php 
session_start();

$_SESSION['SESS_LANGUAGE'] = $_POST['lang'];

print json_encode(array('message' => $_SESSION['SESS_LANGUAGE']));
die();
?>

我真的不知道为什么这段代码在手机上不起作用。

I really don't know why this code doesn't work on the mobile phones.

推荐答案

Cookies 绝对在移动浏览器上工作 。你说我正在寻找萤火虫,这让我觉得你并不是真的在手机上看它。

Cookies definitely work on mobile browsers. You say "I am looking on the firebug" which makes me think you aren't really looking at it on a phone.

你有启动了会话打开错误报告

这篇关于移动浏览器不支持会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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