Jump to content

Storing Value In Cookie


mjnmixael

Recommended Posts

Here is my code.

 

$sql="SELECT user_email FROM $tbl_name WHERE user_login='$myusername' and user_pass='$mypassword'";
$array=mysql_query($sql);
$ekeep=$array[user_email];
setcookie("useremail", $ekeep, time()+60*60*24*100, "/", '.timingishstudios.com');

 

I'm trying to select a specific cell in the table. I can't imagine what isn't working with this script. I don't think I'm grabbing the data correctly.

Link to comment
https://forums.phpfreaks.com/topic/182242-storing-value-in-cookie/
Share on other sites

You need to actually get the record from the mysql resource with a function such as mysql_fetch_assoc. You also are using an undefined constant on this line:

 

$ekeep=$array[user_email];

 

An error might not be thrown depending on how high your error reporting is turned up, but it's still not good to do.

 

$sql="SELECT user_email FROM $tbl_name WHERE user_login='$myusername' and user_pass='$mypassword'";
$result=mysql_query($sql);
$row = mysql_fetch_assoc($result);
$ekeep=$row['user_email'];
setcookie("useremail", $ekeep, time()+60*60*24*100, "/", '.timingishstudios.com');

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.