PHP重定向循环与交叉会话

时间:2013-07-24 01:07:37

标签: php javascript html mysql

问题

在尝试让我的会话能够跨域时,例如。 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>

的index.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>
编辑:它似乎修复了它自己!?我刚刚将.htaccess添加到m.site.com的根目录

0 个答案:

没有答案