Shadowing Posted December 2, 2011 Share Posted December 2, 2011 I"m doing a online tutor and the guy who wrote the tutor his code isnt working. Its supposed to create a cookie but I searched for the cookie and it doesnt exists if someone could please help me id really appreciate it. my server connect file has this code at the top <?php session_start(); ob_start(); then another page with this code below $_SESSION['user_id'] = $row['id'];// this line of code is very important. This saves the user id in the php session so we can use it in the game to display information to the user. $result = mysql_query("UPDATE users SET userip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',login_ip='".mysql_real_escape_string($row['login_ip'])."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'") or die(mysql_error()); // to test that the session saves well we are using the sessions id update the database with the ip information we have received. header("Location: Sample.php"); // this header redirects me to the Sample.php i made earlier if(isset($_SESSION['user_id'])) { // if already logged in. session_unset(); session_destroy(); echo "You have been logged out."; Link to comment https://forums.phpfreaks.com/topic/252335-creating-a-session/ Share on other sites More sharing options...
Shadowing Posted December 2, 2011 Author Share Posted December 2, 2011 I just ran a session test using a view counter and now I understand what a session is lol. no wonder why its not creating a cookie cause there is no create cookie code I thought creating a session was creating a cookie but apparently a session is just something temporary stored on the server. Link to comment https://forums.phpfreaks.com/topic/252335-creating-a-session/#findComment-1293621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.