user2476947
user2476947

Reputation: 25

a cookie from multiple variable

how can I store multiple variable for a variable in one cookie using php? For example variable $name, $password, $latitude, $longitude, store in one variable $seal_cookie, and then create the cookie from variable $seal_cookie. Thank you in advance.

Upvotes: 0

Views: 134

Answers (2)

Barmar
Barmar

Reputation: 781059

Put the variables in an array, and put the array in a cookie:

$seal_cook = array('name'=>$name,
                   'password'=>$password,
                   'lat'=>$latitude,
                   'long'=>$longitude);
setcookie("seal_cookie", serialize($seal_cookie));

When you read the cookie, use unserialize() to get back the array.

Upvotes: 2

Hanky Panky
Hanky Panky

Reputation: 46900

<?php
    $seal_cookie="$name , $password , $latitude , $longitude";
    setcookie("seal_cookie", $seal_cookie);
?>

What was so tough about it?

Upvotes: 1

Related Questions