0

问题

例如,在尝试使我的会话能够跨域时。m.website.com 和 website.com 我以某种方式创建了一个重定向循环。

事情是,当我登录 m.website.com 时,它会像预期的那样进入 /home,但随后它说它有一个重定向循环。我知道会话的事情正在工作,因为如果在此之后我去 website.com/home 我已经登录并且一切都很好。

如果我反过来执行此过程(登录 website.com/home 并尝试转到 m.website.com/home),我也会得到重定向循环。

Sqlconnect.php

$mysql_host = "localhost";
$mysql_database = "";
$mysql_user = "";
$mysql_password = "";

//establish Mysql Connection
mysql_connect($mysql_host, $mysql_user, $mysql_password);
mysql_select_db($mysql_database);

ini_set('session.cookie_domain', '.website.com' );

session_name("webtsite");

m.website.com/home.php

<?php
include "sqlconnect.php";
include "Class.User.php";
session_start();
if(!isset($_SESSION['OK']))
{   
    header("location: index");
    exit;
}
else
{
    $User = new User();
}
if($User->UserInfo['first_name'] == "")
{
    mysql_query("UPDATE `social_users` SET `sessionkey`='DEAD' WHERE `sessionkey`='".session_id()."'") or die(mysql_error());
    unset($_SESSION['OK']);
    session_set_cookie_params(0);
    session_destroy();
    setcookie("PHPSESSID", time()-3600);
    session_regenerate_id(true);
    header("location: index");
}
?>
<?php
    include "header.php";
?>
<title>Website Home</title>
<script type="text/javascript">
$(document).ready(
 function()
 {
  $('div#shoutloader').hide();
  $('div#shoutloader').delay(5000).fadeIn();
 }
);
var loadme = true;
function Loadfeedresults(){
    if(loadme == true){
        loadme == false;
 $('div#feed_loader').show();
 $.ajax({
 url: "feed_load_more_results.php?last_post="+ $(".feedItem:last").attr('id') ,
 success: function(html) {
 if(html){
 $('div#feed_loader').hide();
 $("#feed").append(html);
 }else{
 $('div#loadmore').hide();
 $('div#feed_more').fadeIn();
 $('div#feed_loader').hide();
 }
 }
 });
 }
}
</script>
</head>

<?php
    include "navigation.php";
?>
<div id="content">
  <div id="shout"> <font  size="5">Shout out!</font>
    <form  method="post" action="shout.php" enctype="multipart/form-data">
      <textarea name="shout" class="shoutbox" ></textarea><br />
      Add an image &raquo;<input type="file" placeholder="Upload" name="file"><br />
      Set a mood &raquo; <input type="text" id="mood" class="mood" name="mood" placeholder="Type a mood *optional" maxlength="20"><br />
      <input type="submit" class="shoutbox_submit" name="submit" value="SHOUT!">&nbsp;
    </form>
  </div>
  <div id="shout_divider"></div>
  <div id="feed">
        <center>
            <img src="http://sociobubble.com/images/ajax-loader.gif" />
        </center>
  </div>
  <div style="margin-bottom: 10px;" class="noshouts" id="shoutloader">
    <div id="loadmore">
        <a style="cursor:pointer;" onClick="Loadfeedresults();">Load More Shouts</a>
    </div>
    <div id="feed_more" style="display:none;">No More Shouts</div>
    <div id="feed_loader" style="display:none;">
        <center>
            <img src="http://sociobubble.com/images/ajax-loader.gif" />
        </center>
      </div>
  </div>
</div>

索引.php

    <?php
include "sqlconnect.php";
session_start();
if(isset($_SESSION['OK']))
{   
    header("location: home");
    exit;
}
else
{
}
?>
<?php
    include "header.php";
?>
<title></title>
</head>
<body class="loginbody">
    <div class="content">
        <div class="logo">
            <img width="350px" src="http://.com/images/logo.png">
        </div>
        <div class="login">
            <form method="post" action="login.php">
                Username:<br />
                <input type="text" name="email" class="login_field"><br />
                Password:<br />
                <input type="password" name="password" class="login_field"><br /><br />
                <input type="submit" class="login_submit" value="Login"><br />
                <p style="font-size: 150%;">Or register <a href="">here</a></p>
            </form>
        </div>
    </div>
</body>
</html>

编辑:它似乎是自己修复的!?我刚刚在 m.site.com 的根目录中添加了一个 .htaccess

4

0 回答 0