Pass Javascript Session Cookie to LiveCode Variable?

Rick Harrison harrison at all-auctions.com
Wed Nov 4 20:12:40 EST 2020


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




More information about the use-livecode mailing list