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 
> <use-livecode@lists.runrev.com>:
> 
> 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:
> 
> <script language="JavaScript">
> <!--
> // Set the Value of the Session Variable
> sessionStorage.setItem("firstname", "John");
> sessionStorage.setItem("lastname", "Smith");
> //-->
> </script>
> 
> 
> One would retrieve the session variable in Javascript this way:
> 
> 
> <script language="JavaScript">
> <!--
> // Retrieve
> document.getElementById("JSNewFirstName").innerHTML = 
> sessionStorage.getItem("firstname");  
> document.getElementById("JSNewLastName").innerHTML = 
> sessionStorage.getItem("lastname");
> //-->
> </script>
> 
> 
> In LiveCode one would set a session variable like this:
> 
> <?lc
> 
> start session
> 
> put “Matthias” into VarFirstName
> 
> put VarFirstName into $_SESSION["NewFirstName”]
> 
> stop session 
> 
> ?>
> 
> To retrieve the session variable in LiveCode:
> 
> <?lc
> 
> 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 
>> <use-livecode@lists.runrev.com> 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

Reply via email to