Pass Javascript Session Cookie to LiveCode Variable?

matthias_livecode_150811 at m-r-d.de matthias_livecode_150811 at m-r-d.de
Fri Nov 6 06:04:17 EST 2020


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


-
Matthias Rebbe
Life Is Too Short For Boring Code

> Am 06.11.2020 um 03:54 schrieb Rick Harrison via use-livecode <use-livecode at lists.runrev.com>:
> 
> Hi Matthias,
> 
> I found the problem.
> 
> You had:  put $_Cookie["username”] 
> 
> It shouldn’t have the quotes.
> 
> put  $_Cookie[username]
> 
> works fine.
> 
> I think I made the same mistake sometime!  LOL
> 
> Cookies reside in the client’s web-browser which is why
> as users were are always clearing them out.
> 
> So, LiveCode can read Javascript cookies!  Yay!
> 
> It’s good enough for now.  I’ll revisit Javascript session variables later.
> 
> Thanks for your help!
> 
> Rick
> 
>> On Nov 4, 2020, at 2:04 PM, matthias rebbe via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>> Hi Rick,
>> 
>> i just did a quick test and created an html file which wrote a cookie with javascript
>> 
>> <script type="text/javascript"> 
>> document.cookie = "username=Rick"; 
>> </script>
>> 
>> Then in LC Server i used the array $_cookie to read the content of the cookie
>> 
>> Doing a
>> put $_Cookie["username"] 
>> 
>> returned  Rick
>> 
>> 
>> Regards
>> Matthias
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list