将会话变量传递到新选项卡

时间:2017-06-20 17:59:08

标签: javascript php tabs

我正在尝试将会话变量传递到一个新的选项卡中,该选项卡在我的PHP脚本中打开,因此我可以以相同的顺序多次循环脚本。但是,$ _SESSION数据似乎没有传递到新选项卡。

以下是原始标签中的代码:

if ($dir = opendir($filefolder)) {
        $fileCount = 0;
        while (($file = readdir($dir)) !== false) {
            echo "filename: " . $file . " " . filemtime($filefolder . $file);
            $fileInfo = new SplFileInfo($file);
            if (filemtime($filefolder . $file) > $lastcheck &&*/ $fileInfo->getExtension() == '7z') {
                copy($filefolder . $file, $workingFolder . $file);
                $_SESSION{'filename'} = $file;
                $_SESSION['filepath'] = $workingFolder . $file;
                ?>
                    <script>
                        workingWindow = window.open("<?php xecho($set->url); ?>/?module=upload&mode=automatic&step=0");
                    </script>
                <?php
                $fileCount++;   
            }
        }

以下是新标签中的代码:

$filefolder = $_SESSION['filepath'];
$filename   = $_SESSION['filename'];
$filepath   = $filefolder . $filename;

我在新标签上看到的错误是:

Notice: Undefined index: filepath in C:\xampp\htdocs\datascrape\lib\functions\modules\upload\automatic\automaticStep0.php on line 22

Notice: Undefined index: filename in C:\xampp\htdocs\datascrape\lib\functions\modules\upload\automatic\automaticStep0.php on line 23

1 个答案:

答案 0 :(得分:0)

 $_SESSION{'filename'} = $file;
 $_SESSION['filepath'] = $workingFolder . $file;

将$ file放入SESSION的代码不应该有方括号吗?

 $_SESSION['filename'] = $file;
 $_SESSION['filepath'] = $workingFolder . $file;