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

 

 

Link to comment
Share on other sites

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

Link to comment
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.