Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

dynamically assigning cookies in PHP?

Explorer ,
Oct 25, 2010 Oct 25, 2010

Copy link to clipboard

Copied

HI all.. I know enough of the DW8 behaviors to retrieve a mySQL table record, and place field values on the page.. but what I need to do is assign a cookie on that page... where the cookie name value is pulled from a mySQL record. This means manually coding it no doubt, but I can't figure out the context of the statement to assign a dynamic value to a cookie. Help???

TOPICS
Server side applications

Views

705
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 25, 2010 Oct 25, 2010

Copy link to clipboard

Copied

have you looked here:

http://www.w3schools.com/php/func_http_setcookie.asp

<?php

$value = $your_recordset_row['recordset_value'];

// send a cookie that expires in 72 hours
setcookie("Cookie_Name",$value, time()+3600*72);
?>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 25, 2010 Oct 25, 2010

Copy link to clipboard

Copied

This is the problem.. even in your example the cookie name is hard coded to "Cookie_name" .. but this is the value I need to populate from a dynamic value...

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 25, 2010 Oct 25, 2010

Copy link to clipboard

Copied

LATEST

I dont know the first thing about php, but would have to guess it would be as simple as:

<?php

$value = $your_recordset_row['recordset_value'];

$cookieName = $your_recordset_row['recordset_cookieName'];

// send a cookie that expires in 72 hours
setcookie("$cookieName",$value, time()+3600*72);
?>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines