Return cookie values as JSON

Hi All

I’ve succeeded in writing a cookie and saving form data to it.

Now to read the data back.

I have a PHP file (below) but was wondering how does one return the values in JSON or any other format so that I can populate notifier1?

<?php $email = $_COOKIE['email']; $name = $_COOKIE['name']; $ip = $_COOKIE['ip']; $province = $_COOKIE['province']; $muni = $_COOKIE['muni']; $muni_name = $_COOKIE['muni_name']; $rates_no = $_COOKIE['rates_no']; $mobile_no = $_COOKIE['mobile_no']; $email_ST = $_COOKIE['st']; $node_id = $_COOKIE['node_id']; ?>

Usually, I end of a select PHP with this

$values = mysqli_query($dbc, “SELECT DISTINCT bus_prof FROM bus_dir”);
$rows = array();

while($r = mysqli_fetch_assoc($values)) {

  • $rows = $r;*

print json_encode($rows);
Im assuming its something similar???

or I thought to populate an array

function dofoo() {
    $array["a"] = "Foo";
    $array["b"] = "Bar";
    $array["c"] = "Baz";
    return $array;

$foo = dofoo();

blocks - 2021-07-04T001901.479

I’m just a bit confused, why are you writing all of this data to cookies?

well, I was using the IP till I realized the IP changes all the time so I thought to do a cookie and read it when the user opens the app up again

The IP changing is like the user uninstalling your application then installing it again.

no… as I understand it

as the user moves around and the mobile aquires a new IP?

The device will only acquire a new IP when switching between cellular data and Wi-Fi. The device can also acquire a new IP if the Wi-Fi has a dynamic IP, which is an IP that changes within a certain timeframe.

… and that is why I’m using (or trying to use cookies instead of relying on what might be an old obsolete IP

But more to the piopint.

How can I read back the cookie content into the app. That is the question?

Hi Nathan

Ok, Ive cuut it down to one value but I still donnt know how to get the valse back from the cookie file

Please can you help