我有一个在 / 级别上运行的用户登录会话,它工作正常,然后我有一个 javascript 正在调用文件 /php/ajax.php 以使用数据库后端。事情是我希望将会话数据从初始登录/级别传输到 ajax.php,但它没有。对这个话题有任何合理的想法吗?
登录页面检查:
<?php
session_start();
echo session_id();
if(!isset($_SESSION['loggedin']))
{
die("To access this page, you need to <a href='login.php'>LOGIN</a>");
}
define('WP_USE_THEMES', false); //loads wordpress
require('/home/content/70/9551370/html/alpha/wordpress/wp-blog-header.php');
query_posts('showposts=1');
?>
<head>
<link href="css/style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/page.css" /-->
<link rel="stylesheet" type="text/css" href="css/chat.css" />
<head>
<body>
<div class="background_container" style="">
<div style="text-align:center;">
<table style="text-align:center;"><!--three column division-->
<tr>
<td id="chat">
<div id="chatContainer">
<div id="chatTopBar" class="rounded"></div>
<div id="chatLineHolder"></div>
<div id="chatBottomBar" class="rounded">
<div class="tip"></div>
<form id="loginForm" method="post" action="">
<input id="name" name="name" class="rounded" maxlength="16" />
<input id="email" name="email" class="rounded" />
<input type="submit" class="blueButton" value="Login" />
</form>
<form id="submitForm" method="post" action="">
<input id="chatText" name="chatText" class="rounded" maxlength="255" />
<input type="submit" class="blueButton" value="Submit" />
</form>
</div>
</div>
<!--table>
<tr>
<td class="window_top"></td>
</tr>
<tr>
<td class="window_bottom"><div>chat form goes here</div></td>
</tr>
</table-->
</td>
<td class="lesson"><!--Wordpress posts-->
<?php while (have_posts()): the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" class="text1">Read more...</a>
<?php endwhile; ?>
</td>
<td><!--End Wordpress-->
<h2>Tracking</h2>
<p><?php Print_r ($_SESSION); ?></p>
<form action="" method="">
<ul id="grade_list" style="list-style:none;">
<li>1. <Input type = 'radio' Name ='lesson1' checked="checked" value= 'yes'>Yes</input>
<Input type = 'radio' Name ='lesson1' value= 'no'>No</input>
</li>
<li>2. <Input type = 'radio' Name ='lesson2' checked="checked" value= 'yes'>Yes</input>
<Input type = 'radio' Name ='lesson2' value= 'no'>No</input>
</li>
<li>3. <Input type = 'radio' Name ='lesson3' checked="checked" value= 'yes'>Yes</input>
<Input type = 'radio' Name ='lesson3' value= 'no'>No</input>
</li>
</ul>
<Input type = "Submit" Name = "Submit1" Value = "Submit">
</form>
</td>
</tr>
</table>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="js/jScrollPane/jquery.mousewheel.js"></script>
<script src="js/jScrollPane/jScrollPane.min.js"></script>
<script src="js/script.js"></script>
</body>
阿贾克斯.php:
<?php
$dbOptions = array(
'db_host' => 'ip',
'db_user' => 'user',
'db_pass' => 'password',
'db_name' => 'db_name'
);
/* Database Config End */
error_reporting(E_ALL ^ E_NOTICE);
require "classes/DB.class.php";
require "classes/Chat.class.php";
require "classes/ChatBase.class.php";
require "classes/ChatLine.class.php";
require "classes/ChatUser.class.php";
session_start();
...
?>