My session ID's stopped working

不问归期 提交于 2020-01-06 15:23:12

问题


I have been working on writing a program and the session ID's have been working for several days. Now all of a sudden they are not working anymore. Any advice? The script codes are below for the test script I wrote to test passing the session ID's.

This is how I have the login page started, with no line breaks before this code.

<?php session_start();
?>
<!--HTML HEADER-->
<form action="sessionID.php" method="post">
name: <input name="stName" type="text" /><br/>
pass: <input name="newPass" type="text" /><br/>
<input name="" type="submit" value="submit"/>
</form>

It is passed through another page to test passing through a HREF link. Here is the top of that script.

<?php session_start();
$_SESSION['student']=$_POST['stName'];

Final page to echo the session ID.

<?php session_start();
$student = $_SESSION['student'];
echo session_id();

Anything I am doing wrong...?


回答1:


You saved your value to $_SESSION['student']

Use:

<?php session_start();

$student = $_SESSION['student'];

//echo session_id(); 

echo $student;

?>




回答2:


Echoing session_id(); will echo a series of number/letters, and not the actual name.

In order to echo the (student) name of the input given from a form is:

echo $_SESSION['student'];



回答3:


When I redirected after verifying username password, I used http://www.domainname. I switched the redirect to http://domainname (no www.) and $_SESSION['user'] works perfect.



来源:https://stackoverflow.com/questions/18669613/my-session-ids-stopped-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!