Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.