不可能。location.href还是同一个ie窗口。
不会影响session,你程序有问题,代码帖出来.

解决方案 »

  1.   

    ok,在这里我只能写个大概的。index.php<html>
    <head>
    <script language=javascript>
    function nextPage(pageName)
    {
        if (checkLen() == true) {
            document.main.flag.value="1";
            document.main.submit();
        }
    }</head>
    <body>
    <form name=main action="index.php" method=post>
    <input type=password name=password>
    <input type="hidden" name="flag">
    <img src="login.gif" style="cursor:hand" onclick="nextPage('page.htm');">
    </form>
    <?php
        $contents;
        if ($HTTP_POST_VARS["flag"] == "1")
        {
            unset($HTTP_POST_VARS["flag"]);
            echo "<script language=javascript>";
            if ($HTTP_POST_VARS["password"] == "123")
                {             session_start();
                 session_register("password");
                 echo "top.location.href='page.php'";             
                }
            else
                echo "window.alert('密码输入不正确!');";
            echo "</script>";
        }
    ?>
    </body>
    </html>page.php<?
      session_start();
      if(!session_is_registered("password"))
        {
               echo "<script language=javascript>alert(\"请先登陆\");";
               echo "top.location.href=\"index.php\";";
               echo "</script>";
        }
    ?>
    <html>
    <head></head>
    <body>
    welcome
    </body>
    </html>代码如上,在page.php一开始我加入了session检查是否有注册了password,注册了就代表已经登陆,正常显示页面。否则就是没有登陆过,回到登陆页面。但因为用的是top.location.href="page.php",所以两个页面虽然在一个浏览器,但sessionid是不同的。似乎相当于在这个浏览器中输入了page.php这个地址。所以无法实现相同的sessionid。
    你也可以试试。实际的情况比这个复杂,因为我的页面用还带了其它的页面。
    望得到一个满意的答案。
      

  2.   

    在下面这句话前面
    session_register("password");
    加上:
    $password=$HTTP_POST_VARS['password'];try:
    a.php
    <?
    $name="asfdafd";
    session_register("name");
    ?>
    <input type=button value=go onclick="location.href='b.php'">
    b.php
    <?
    session_start();
    echo $HTTP_SESSION_VARS['name'];
    ?>
      

  3.   

    如果版本较新,可以尝试不使用session_register,而变成直接修改SESSION变量数组.
    将wasy的文件做如下修改:
    a.php
    <?
    session_start(); // wasy你是session_autostart,忘了这个吧
    $HTTP_SESSION_VARS["name"]="asfdafd";
    ?>
    <input type=button value=go onclick="location.href='b.php'">
      

  4.   

    to 小菜虎:
    session_register()不用session_start();session_register:
    If session_start() was not called before this function is called, an implicit call to session_start() with no parameters will be made.
      

  5.   

    问题解决了,不过你们的方法还是不行。不信你们可以try。我用的php是cgi的。
    我用的方法其实很简单,在<? echo"top.location.href='b.php?".SID."'"?>
    To wasy:
    在下面这句话前面
    session_register("password");
    加上:
    $password=$HTTP_POST_VARS['password'];我的register.globals=On
    所以不用加。
      

  6.   

    总结:
    再用location.href="next.php" 时,即使在一个IE窗口中sessionid也会变化,要传递sessionid,必须改成"location.href='next.php?".SID."'"。不同的是如果在页面index.php中有一个<a href="next.php">link</a>时,点击这个连接,sessionid会自动保留,不用加SID了。当然这可能和php.ini的设置有关。
      

  7.   

    总结:
    在用location.href="next.php" 时,即使在一个IE窗口中sessionid也会变化,要传递sessionid,必须改成"location.href='next.php?".SID."'"。不同的是如果在页面index.php中有一个<a href="next.php">link</a>时,点击这个连接,sessionid会自动保留,不用加SID了。当然这可能和php.ini的设置有关。
      

  8.   

    当然这可能和php.ini的设置有关。不是很可能是,是一定是!!!
    我在公司就是,在我机器不好使,在同事机器就好使,
    就是这种情况。:(
    具体原因不明!
      

  9.   

    照tjsparkle(rock) 这种说法,就是不能在你的机器使用cookie方法传递session变量了……
      

  10.   

    照tjsparkle(rock) 这种说法,就是不能在你的机器使用cookie方法传递session变量了……