Insert cookies data into MySQL database in PHP? [d

2019-09-22 03:12发布

Possible Duplicate:
How to get offline cookies data with php and insert it in mysql?
Get cookies in php?

I have some users information saved in cookie, the users information are like this,

Fname:Muhammad,Lname:Riaz,title:Developer,org:MagicLamp,email:riaz@yaho.com Fname:Fraz,Lname:Khan,title:Developer,org:MagicLamp,email:riaz@yaho.com

I want to insert these information in to MySQL database. The problem is this: how can I get this information from a cookie and insert into database?

2条回答
做个烂人
2楼-- · 2019-09-22 03:42
$str = "";

foreach ($_COOKIE as $key => $value)
{
    $str .= $key . ":" . $value . ",";
}

$str = substr($str, 0, -1);
查看更多
贪生不怕死
3楼-- · 2019-09-22 03:53

Please check this out: $_COOKIE

After getting the cookie you can use pdo or mysqli to insert the data into the database.

Make sure you clean the data before inserting into the db.

查看更多
登录 后发表回答