Jump to content

Modifying a script to store information into a table rather then a cookie


Recommended Posts

Currently I am using the following script to store cookies

if(isset($_GET['activelocation'])){
$activelocation = $_GET['activelocation'];
setcookie('location', $activelocation, time()+60*60*24*30);
} elseif(isset($_COOKIE['location'])){
$activelocation = $_COOKIE['location']; //if the cookie is set, get the value
} else{
setcookie('location', 'New York, NY', time()+60*60*24*30);
$activelocation = "New York, NY";
}

 

But I realized that being I anyway have registered users on the my site, it would probably be better of storing it in their account preferences.

How would I go about modify this so that instead of creating a cookie it stores it into a field in my user table?

Also, I would want it that if the user is not logged in, then it will use cookies, but first it should look to see if person is logged in, and rather use that

 

Thanks

Select would take out the items from your mysql, and you use mysql_fetch_assoc or fetch object to echo it

 

:)

 

(if im not mistaken!)

 

an example:

 

$usersql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'");

$user = @mysql_fetch_object($usersql);

 

now, all colums in your database are stored with the variable $user

 

to echo a column, you would type echo "$user->(columnname)";

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.