Enable Cookies on device

Hi All

I need to do the cookie thing when Screen1 initiates

Question is

How do I read back the value (ip) stored in the cookie later in the app?*

I know it works

done_ip

Thanks

t

If you have use webviewer and set cookie then use document.cookie; in evaluate JS to get cookie.

1 Like

like this??
document_cookie

1 Like

Use evaluate javascript

1 Like

eval_cookie
Thanks

If I use this, how do I get the value out?

Screenshot 2021-10-25 at 1.39.38 PM

1 Like

ah, of course. How stupid can one be.

Thanks

1 Like

COOKIEBLOCKS

So, would this make sense to you

I create the cookie with a php file???

<?php
function dataFilter( $data ) {
$data = trim( $data );
$data = stripslashes( $data );
$data = htmlspecialchars( $data );
return $data;
}

// variable
$token ="";

// GET variable
$token = dataFilter($_GET['token']);

// assign variable
$value = '$token';

// SET COOKIE NAME AND VALUE AND DURATION
setcookie("token", $value, time()+60*60*12); /* expire in 12 hour */
// setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);

?>

id_cookie

will this hekp identify the cookie?

1 Like

LOOKS A IF IT WORKED???

WORKED

just use document.cookie to get cookies

Thanks

I was thinking if there were many cookies how would it know which one?

I read it returns all the cookie values in an array of sorts???

am I wrong?

if I wanted to use the blocks to create instead of php

what would the URL be???

Can you clearly explain what do you want to do ?

1 Like

Ok, so Im trying to negate the neccecity fo someone to log in depending on the value in the cookie

So I create the cookie the first Login

and thereafter

Whenever the login screen pops up, it reads the value of the cookie and if the value is there, it auto goes to another screen

BTW

Thanks

null

I removed the extra stuff after the document.cookie but Im getting a null

1 Like

As you asked earlier, document.cookie returns all the cookies but not in an array format. it returns by separating cookies using ;
Example- cookie1=value; cookie2=value; cookie3=value;
You can easily split them using text_split

1 Like

but all im getting is null

will it work in Companion???

might that be the problem

phpworks

1 Like