Jump to content

[SOLVED] Cookie variable isn't showing correctly...


therealwesfoster

Recommended Posts

Please read the whole thread before replying. Thanks :)

 

The title of this topic is kind of confusing, but I couldn't think of a perfect one real quick.

 

But check this out. After someone logs in, they get a cookie called ukey and it's value is: 1;77c69387a8c3c1ac68dc654e3652a690 (changing for each user, but i'm using me as example.)

 

The 1 is the user_id, separated from a hashkey with a semi-colon.

 

On every page, I have it explode the cookie like so:

$ukey = $_COOKIE['ukey'];
list($id, $key) = explode(";",$ukey);

 

I then echo the 2 vars.. it comes out like so:

ID = 1
KEY = 

 

Why is the KEY left blank when it should be 77c69387a8c3c1ac68dc654e3652a690

 

Thanks

 

 

K.

 

<?php
		$sql = mysql_query(" SELECT THE USER INFO ") or die("Cant figure out who the heck you are...<br />".mysql_error());
		$user = mysql_fetch_array($sql);

		$key_string = $user['user_id'].";".md5($the_hash_variable);

		$_SESSION['ukey'] = $key_string;

		if ( isset($cpost['i_remember']) ) // if we want a cookie set
		{
			setcookie("ukey", $key_string);
		}
?>

 

^ That sets the cookie

 

 

Also, i've echo'd the $ukey variable on a page BEFORE exploding it, and it only returns 1.. weird

 

THIS IS WHAT IT IS

COOKIE: 1

Username: Wesf90

ID: 1

KEY:

 

 

THIS IS WHAT IT SHOULD BE

COOKIE: 1;77c69387a8c3c1ac68dc654e3652a690

Username: Wesf90

ID: 1

KEY: 77c69387a8c3c1ac68dc654e3652a690

 

 

And when i view my cookies, the cookie show the 1;HASH correctly

You do know that you are not setting a time on your cookie right?  So it will expire when you close your browser.

 

Thanks, I will set it.

 

BUT, thats not the issue, like I said:

"And when i view my cookies, the cookie show the 1;HASH correctly"

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.