Safari 5.1 中不允许 <video>检测 $_SESSION 变量的源 [英] Safari 5.1 in doesn't allow <video> source to detect $_SESSION variables

查看:38
本文介绍了Safari 5.1 中不允许 <video>检测 $_SESSION 变量的源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 download.php 脚本,它检测用户是否使用 $_SESSION 变量登录,并向用户读出视频文件.如果我从 Safari 5.0.5 中的元素调用它,脚本会检测会话变量并按预期工作.在 5.1 中,download.php 不读取会话变量,它的行为就像用户未登录一样.如果我直接从地址栏中调用脚本,它工作正常.如果我从我的 iPhone 打电话,它也会被检测到.有谁知道这是一个错误还是有解决方法?我将不得不重新编写很多内容以尝试不使用会话.谢谢.

这是一个故障排除脚本.这显示了正确的会话数据:

<!DOCTYPE html><html lang="zh-cn"><头><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>测试</title><身体><video width="640" height="480" controls="true" autoplay="false" id="v"><source src="video.php" type="video/mp4"/></视频><?phpecho "

";var_dump($_SESSION);echo "</pre>";?></html>

每次加载上述页面时都会写入未检测到会话",但使用 Safari 5.0.5 和 iOS 检测到会话:

Safari Inspector 将调用 video.php 的状态显示为待处理",并且除了请求 url 之外没有其他标题.修复了 session_start,但仍然有效.

好的,如果我读取 SERVER 变量,5.1 和 5.0.5 之间的区别在于 5.0.5 具有:HTTP_CONNECTION => 关闭,并且 HTTP_COOKIE 包含一个 PHPSESSID

我在 32 位模式下运行 Safari,它再次运行......

解决方案

如果 cookie 没有自动传递给由

I have a download.php script that detects if a user is logged in with a $_SESSION variable, and reads out a video file to the user. If I call this from a element in Safari 5.0.5, the script detects the session variable and works as expected. In 5.1 the session variables are NOT read by the download.php and it acts like the user isn't logged in. If I call the script directly from the address bar, it works fine. If I call from my iPhone, it is detected as well. Does anyone know if this is a bug or if there's a work-around? I would have to re-write a lot to try and not use sessions. Thanks.

Here's a troubleshooting script. This shows the correct session data:

<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Test</title> 
    </head>
    <body>
        <video width="640" height="480" controls="true" autoplay="false" id="v">
            <source src="video.php" type="video/mp4" />
        </video>
        <?php
        echo "<pre>";
        var_dump($_SESSION);
        echo "</pre>";
        ?>
    </body>
</html>

This writes 'Session Not Detected' every time I load the above page, but the session is detected with Safari 5.0.5 and iOS:

<?php
session_start();

// write local error log
function write_log($txt) {
    $myFile = 'error.log';
    $fh = fopen($myFile, 'a') or die("can't open file");
    fwrite($fh, "$txt\n");
    fclose($fh);
}

if ($_SESSION) {
    write_log(date('Y-m-d H:i:s'). ' Session Detected');
} else {
    write_log(date('Y-m-d H:i:s'). ' Session Not Detected');
}

?>

EDIT: Safari Inspector shows the status of calling video.php as 'pending', and has no headers other than the request url. Fixed the session_start, but still works the same.

EDIT: Okay if I read the SERVER variables, the difference between 5.1 and 5.0.5 is that 5.0.5 has: HTTP_CONNECTION => close, and HTTP_COOKIE contains a PHPSESSID

EDIT: I ran Safari in 32 bit mode and it worked again...

解决方案

If cookies aren't automatically passed to the script called by a <video> element, you could just pass the PHPSESSID as a GET parameter so on the page where the video is embedded, you put something like:

<video ...>
    <source src="video.php?PHPSESSID=<?php echo session_id(); ?>" type="video/mp4" />
</video>

这篇关于Safari 5.1 中不允许 &lt;video&gt;检测 $_SESSION 变量的源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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