Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-06 Thread Rick Harrison via use-livecode
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:



var amount1 = 23;
var amount2  = 56;
var total = amount1 + amount2; 

document.cookie = "AdditionResult=" + total + ";"




"
put "VarAdditionResult = " & VarAdditionResult
put ""

?>

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 
>  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
> 
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-06 Thread matthias rebbe via use-livecode
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 
> :
> 
> 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 
>>  wrote:
>> 
>> Hi Rick,
>> 
>> i just did a quick test and created an html file which wrote a cookie with 
>> javascript
>> 
>>  
>> document.cookie = "username=Rick"; 
>> 
>> 
>> 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@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-05 Thread Rick Harrison via use-livecode
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 
>  wrote:
> 
> Hi Rick,
> 
> i just did a quick test and created an html file which wrote a cookie with 
> javascript
> 
>  
> document.cookie = "username=Rick"; 
> 
> 
> 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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-05 Thread matthias rebbe via use-livecode
Rick,

you are mixing something.

$_session array is stored on the server while sessionstorage is stored on the 
clients computer.

I am not sure that there is a direct way to let Livecode Server read 
sessionstorage directly from the clients computer, but i might be wrong.
At least PHP is not able.

One way would be to use Javascript to read the storagesession and post it to a 
LC Server script using Ajax. 
You could even do this from one single LC server script.
In the script you would check if the $_POST array contains any data. 
If the $_POST array is empty, then you have to execute  the javascript that 
fetches the sessionstorage data and if there is sessionstorage  then it posts 
that data to the script again.
If the $_POST array is not empty, then you can continue the script using the 
sessionstorage data.

At least this is the way how it is done in .php

I've used this method a lot for processing form data.

HTH

Matthias




> Am 05.11.2020 um 02:12 schrieb Rick Harrison via use-livecode 
> :
> 
> Hi Matthias,
> 
> Session Variables are like cookies except they auto-expire at the end of a 
> browser session
> like when you close a tab or window.
> 
> In Javascript one would set a session variable this way:
> 
> 
> 
> 
> 
> 
> One would retrieve the session variable in Javascript this way:
> 
> 
> 
> 
> 
> 
> 
> In LiveCode one would set a session variable like this:
> 
>  
> start session
> 
> put “Matthias” into VarFirstName
> 
> put VarFirstName into $_SESSION["NewFirstName”]
> 
> stop session 
> 
> ?>
> 
> To retrieve the session variable in LiveCode:
> 
>  
> start session
> 
> put  $_SESSION["NewFirstName”] into VarFirstName 
> 
> stop session 
> 
> ?>
> 
> So, I’m wondering that since we are able to have LiveCode retrieve Javascript 
> cookies,
> then perhaps it can retrieve Javascript session variables too.
> 
> I just haven’t quite made the connection yet.
> 
> Your thoughts?
> 
> Rick
> 
>> On Nov 4, 2020, at 7:00 PM, matthias rebbe via use-livecode 
>>  wrote:
>> 
>> What do you mean with session variables? 
>> 
>> To be honest i am not very used with Javascript. 
>> I just did a quick test to write a cookie with JS and read it with LC 
>> server. ;)
>> 
>> Regards,
>> Matthias
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



-
Matthias Rebbe
Life Is Too Short For Boring Code


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-04 Thread Rick Harrison via use-livecode
Hi Matthias,

Session Variables are like cookies except they auto-expire at the end of a 
browser session
like when you close a tab or window.

In Javascript one would set a session variable this way:






One would retrieve the session variable in Javascript this way:







In LiveCode one would set a session variable like this:



To retrieve the session variable in LiveCode:



So, I’m wondering that since we are able to have LiveCode retrieve Javascript 
cookies,
then perhaps it can retrieve Javascript session variables too.

I just haven’t quite made the connection yet.

Your thoughts?

Rick

> On Nov 4, 2020, at 7:00 PM, matthias rebbe via use-livecode 
>  wrote:
> 
> What do you mean with session variables? 
> 
> To be honest i am not very used with Javascript. 
> I just did a quick test to write a cookie with JS and read it with LC server. 
> ;)
> 
> Regards,
> Matthias

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-04 Thread matthias rebbe via use-livecode
What do you mean with session variables? 

To be honest i am not very used with Javascript. 
I just did a quick test to write a cookie with JS and read it with LC server. ;)

Regards,
Matthias
-
Matthias Rebbe
Life Is Too Short For Boring Code



> Am 05.11.2020 um 00:31 schrieb Rick Harrison via use-livecode 
> :
> 
> Hi Matthias,
> 
> Well, that works fine!
> 
> I’ll have to study what I did differently to figure why my method didn’t work.
> 
> Will this work with Session variables too?
> 
> Thanks,
> 
> Rick
> 
>> On Nov 4, 2020, at 4:35 PM, matthias rebbe via use-livecode 
>>  wrote:
>> 
>> Hi Rick,
>> 
>> there are two files:
>> 
>> writecookies.html
>> readcookies.lc 
>> 
>> See the code of each here
>> https://livecode.dermattes.de/javascript/showcode.lc 
>> 
>> 
>> -
>> Matthias Rebbe
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-04 Thread Rick Harrison via use-livecode
Hi Matthias,

Well, that works fine!

I’ll have to study what I did differently to figure why my method didn’t work.

Will this work with Session variables too?

Thanks,

Rick

> On Nov 4, 2020, at 4:35 PM, matthias rebbe via use-livecode 
>  wrote:
> 
> Hi Rick,
> 
> there are two files:
> 
> writecookies.html
> readcookies.lc 
> 
> See the code of each here
> https://livecode.dermattes.de/javascript/showcode.lc 
> 
> 
> -
> Matthias Rebbe

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-04 Thread matthias rebbe via use-livecode
Hi Rick,

there are two files:

writecookies.html
readcookies.lc

See the code of each here
https://livecode.dermattes.de/javascript/showcode.lc

-
Matthias Rebbe
Life Is Too Short For Boring Code

> Am 04.11.2020 um 22:10 schrieb Rick Harrison via use-livecode 
> :
> 
> Hi Matthias,
> 
> I just tried your code and it didn’t go across from one format file to the 
> next.
> 
> I got:   username = “username”
> 
> What’s wrong?
> 
> If you can give me your full code for both mini format files I will try it
> and we can see the results exactly.
> 
> Thanks for helping!
> 
> Rick
> 
>> On Nov 4, 2020, at 2:04 PM, matthias rebbe via use-livecode 
>>  wrote:
>> 
>>  
>> document.cookie = "username=Rick"; 
>> 
>> 
>> Then in LC Server i used the array $_cookie to read the content of the cookie
>> 
>> Doing a
>> put $_Cookie["username"] 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-04 Thread Rick Harrison via use-livecode
Hi Matthias,

I just tried your code and it didn’t go across from one format file to the next.

I got:   username = “username”

What’s wrong?

If you can give me your full code for both mini format files I will try it
and we can see the results exactly.

Thanks for helping!

Rick

> On Nov 4, 2020, at 2:04 PM, matthias rebbe via use-livecode 
>  wrote:
> 
>  
> document.cookie = "username=Rick"; 
> 
> 
> Then in LC Server i used the array $_cookie to read the content of the cookie
> 
> Doing a
> put $_Cookie["username"] 

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pass Javascript Session Cookie to LiveCode Variable?

2020-11-04 Thread matthias rebbe via use-livecode
Hi Rick,

i just did a quick test and created an html file which wrote a cookie with 
javascript

 
 document.cookie = "username=Rick"; 


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


-
Matthias Rebbe
Life Is Too Short For Boring Code

> Am 04.11.2020 um 18:16 schrieb Rick Harrison via use-livecode 
> :
> 
> Greetings LiveCoders,
> 
> I have an LC server format file that uses a Javascript video player.
> The video player has a nice time progress bar that shows how far
> the user has played the video. All of that works just fine.
> 
> What I would like to do is check what that time completion variable
> is when the user clicks on a button to leave the video so I will know
> if they finished watching it all the way to the end of the video or not. 
> I then want to make a note of it in my database which requires that 
> I am able to send that javascript variable value over to a LiveCode
> variable.
> 
> I’ve been looking at Session Cookies to see if LiveCode can read
> a Javascript Session Cookie, but so far have been unsuccessful.
> 
> Ideas, code or suggestions anyone?
> 
> Thanks!
> 
> Rick
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode