Pass Javascript Session Cookie to LiveCode Variable?
Rick Harrison
harrison at all-auctions.com
Fri Nov 6 11:42:15 EST 2020
Hi Matthias,
Hmm, I should never do things when I’m tired.
I do the following all the time with LC session variables
and they do use the quotes.
put $_SESSION["userid"] into Varuserid
Yet the following works nicely and no array is needed:
<script type="text/javascript">
var amount1 = 23;
var amount2 = 56;
var total = amount1 + amount2;
document.cookie = "AdditionResult=" + total + ";"
</script>
<?lc
put $_cookie[AdditionResult] into VarAdditionResult
put "<br><br>"
put "VarAdditionResult = " & VarAdditionResult
put "<br><br>"
?>
So $_cookie[AdditionResult] and $_cookie[“AdditionResult”]
are different variables?
I will have to play around some more. I’m happy that at least
something is working now. I just need to know why.
Cheers,
Rick
> On Nov 6, 2020, at 6:04 AM, matthias rebbe via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> I doubt that the qoutes were the problem. ;)
>
> Your
> put $_cookie[username]
> will replace the content of the var username.
> In your case, if the value of variable username for example is Peter then
> LC would replace $_cookie[username] with $_cookie["Peter"]
>
> If username wasn't used before then LC uses username as the value of username
>
> In this case LC would replace $_cookie[username] with $_cookie["username"].
>
> So for example
> put "hallo" into tArray["mytext"]
> put tArray["mytext"] --returns hallo
> put tArray[mytext] -- returns hallo
> put "test" into mytext
> put tArray[mytext] -- returns nothing
>
> So i am not sure, what the problem was, but definitely not the quotes. ;)
>
> Regards,
> Matthias
>
>
More information about the use-livecode
mailing list