-3

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?

Community
  • 1
  • 1
  • 2 user accounts. 7 copies of this question. – Quentin May 15 '12 at 09:55
  • You allready asked this exact question [here](http://stackoverflow.com/questions/10579504/get-cookies-in-php) and it got rated very low. What makes you think reasking it will give you answers? – Zombaya May 15 '12 at 09:56
  • If the answer you got last time didn't solve the problem, why did you accept it as an answer? – Quentin May 15 '12 at 09:57
  • Downvoted; you should never ask a question multiple times, as it (obviously) creates duplication of effort on your behalf. – halfer May 15 '12 at 10:14
  • Also replicated [here](http://stackoverflow.com/questions/10578599/it-is-possible-to-insert-data-in-two-different-table-in-mysql-by-one-insert-quer)! – halfer May 15 '12 at 10:17
  • 2
    Also [here](http://stackoverflow.com/questions/10578319/how-to-get-offline-cookies-data-with-php-and-insert-it-in-mysql), [here](http://stackoverflow.com/questions/10552685/how-to-get-offline-cookies-data-with-php), and [here](http://stackoverflow.com/questions/10550441/save-my-cookie-data-to-mysql-database), and [here](http://stackoverflow.com/questions/10546717/how-to-save-data-in-mysql-from-cookies-in-php). I wasn't kidding when I said there were 7 copies of it. – Quentin May 15 '12 at 10:19
  • I am new in programming, thanks for telling me my mistakes, and please appreciate me because i am new in programming – user1393109 May 15 '12 at 10:20
  • Good sleuthing Quentin. @user1393109 - please don't be offended if they all get closed. Questions don't get answered instantly on any forum, unless you are paying for the support. And why would you operate two separate accounts? – halfer May 15 '12 at 10:21
  • I operate separate account because the previous account have closed by stackoverflow. so I ask question by this account – user1393109 May 15 '12 at 10:29
  • @user1393109 - are you sure it has been closed? Normally your profile would be marked as suspended (it isn't) and you've not done anything to warrant an account closure (imo). Try again with it (get it to resend you a password), and please, stick to one account, and don't ask a question more than once. You should now have sufficient answered to help you - and don't be afraid to web-search around the answers to get you to the solution you need. – halfer May 15 '12 at 10:36
  • ([This](http://stackoverflow.com/users/285587/your-common-sense) is what a suspended account looks like). – halfer May 15 '12 at 10:37
  • Thanks Halfer to appreciate me...... – user1393109 May 15 '12 at 10:47
  • I am using foreach ($_COOKIE as $key => $value) but it is gets online cookies not offline – user1393109 May 15 '12 at 11:21
  • No, we will not appreciate your unwillingness to learn from your mistakes after they have been pointed out. – BoltClock May 15 '12 at 12:26

2 Answers2

1
$str = "";

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

$str = substr($str, 0, -1);
C. Leung
  • 6,218
  • 3
  • 20
  • 32
  • Thanks for replying and where i would write insert query...... after this code or before, can you help me a little more – user1393109 May 15 '12 at 10:27
  • I am using foreach ($_COOKIE as $key => $value) but it is geting online cookies not offline – user1393109 May 15 '12 at 11:22
  • 1
    @user1393109: Sounds like you could use JavaScript cookies and then retry saving on the server via AJAX. Do some thorough web searching around these topics, and - *strongly recommended* - get a book on PHP web development to learn about the basics first. It will be worth the effort, I am certain. – halfer May 15 '12 at 13:14
0

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.

Adam
  • 1,684
  • 14
  • 18