【发布时间】:2014-02-11 23:20:29
【问题描述】:
我正在创建一个网站,用户在其中创建一个帐户,并启动一个会话。然后,您会被引导到一个包含您创建的帐户的页面(我没有给您原因,这对这个想法很有意义,我也没有给您原因,所以没有人会窃取我的想法: D) ,您必须单击其中一个。完成后,我希望脚本根据您单击的内容创建一个新会话。现在的问题是我不认为 if(isset( 实际上是在 while 循环中运行的,所以当我点击一个帐户时,它会将我带到我创建的一个随机帐户,而不是我点击的那个。代码 : login.php(部分)
$_SESSION['username'] = $username;
header("Location: ....php");
accounts.php
$user = $_SESSION['username'];
echo"
<form action='.....php' method='POST'>
<input type='submit' name='submit_bubble' id='submit_bubble' style='position:relative;margin-left:500px;margin-top:100px;width:400px;height:400px;border-radius:400px;font-family:Tahoma,Arial;font-size:25px;' value='$profile'/>
";
echo "
</input>
</form>
";
if (isset($_POST['submit_bubble'])) {
$_SESSION['profile'] = $profile;
header ("Location:gridtest.php");
}
}
?>
header.php(用于网站的其余部分)
include ( 'mysql_connectinc.php' );
include ( 'functions.php');
function sec_session_start() {
$session_name = 'username'; // Set a custom session name
$secure = false; // Set to true if using https.
$httponly = true; // This stops javascript being able to access the session id.
ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies.
$cookieParams = session_get_cookie_params(); // Gets current cookies params.
session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
session_name($username); // Sets the session name to the one set above.
session_start(); // Start the php session
session_regenerate_id(true); // regenerated the session, delete the old one.
}
$user = $_SESSION['profile'];
$_SESSION['id'] = 'profile';
【问题讨论】:
-
没有人想窃取你的想法。
-
这是一个复杂的想法...需要一段时间来解释,但我有充分的理由制作这个网站
-
我不想让你窃取我的代码,所以我无法回答问题
-
哦,你有充分的理由去做它。凉爽的。大多数网站完全没有任何理由。 (说真的,我们无法用您提供给我们的少量信息来回答您的问题)。
-
不,我不关心代码,你可以复制代码,这只是想法......好吧,就在这里。您登录以选择另一个帐户登录。现在你真的不必知道这背后的原因。对不起,如果我听起来很傲慢。