Quantcast

Manipulating SessionVariables using AJAX

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Manipulating SessionVariables using AJAX

Tom W Robinson
I'm using Jquery .load method to update the DOM and call lassoscript

$("#divupdate").load('jq.lasso',{sessionvariable: sessionvariable});

I thought I would be able to pass a sessionvariable to the jq.lasso file and ->insert ->remove to the sessionvariable array.

My initial tests would indicate otherwise?  Is this possible?  

If not, has anyone done something similar in function to what I'm trying to accomplish below?

I would like to use a sessionvariable (array) to manage a user's favorite products.  Basically when the user logs in to their account I want search the Favorites table and create a session variable so that I can reduce database interactions. When the user wants to add a product to their favorites table I don't want to have to redraw the page.  I would like to use the Jquery .load method and on the jq.lasso page I want to Add that product to the database,Insert the product into the session variable array and send a simple alert.

I've got the entire solution except for manipulating the sessionvariable array to reduce database interactions.

Thanks!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating SessionVariables using AJAX

Jolle Carlestam-2
Lasso 8 or 9?

HDB
Jolle

Sent from a mobile device. Any anomalies is due to Autocorrect.

> 27 sep. 2016 kl. 17:21 skrev Tom W Robinson <[hidden email]>:
>
> I'm using Jquery .load method to update the DOM and call lassoscript
>
> $("#divupdate").load('jq.lasso',{sessionvariable: sessionvariable});
>
> I thought I would be able to pass a sessionvariable to the jq.lasso file and
> ->insert ->remove to the sessionvariable array.
>
> My initial tests would indicate otherwise?  Is this possible?  
>
> If not, has anyone done something similar in function to what I'm trying to
> accomplish below?
>
> I would like to use a sessionvariable (array) to manage a user's favorite
> products.  Basically when the user logs in to their account I want search
> the Favorites table and create a session variable so that I can reduce
> database interactions. When the user wants to add a product to their
> favorites table I don't want to have to redraw the page.  I would like to
> use the Jquery .load method and on the jq.lasso page I want to Add that
> product to the database,Insert the product into the session variable array
> and send a simple alert.
>
> I've got the entire solution except for manipulating the sessionvariable
> array to reduce database interactions.
>
> Thanks!
>
>
>
>
>
> --
> View this message in context: http://lasso.2283332.n4.nabble.com/Manipulating-SessionVariables-using-AJAX-tp4645507.html
> Sent from the Lasso - Talk mailing list archive at Nabble.com.
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating SessionVariables using AJAX

Tom W Robinson
I'm using Lasso 9.3.1

Thanks Jolle
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating SessionVariables using AJAX

Jolle Carlestam-2
Let’s assume you’re using cookie based sessions.
If you are then the session id is handled as it would be with any regular page call and all you should do is send whatever data you want to store with your session i the AJAX call.

On the landing page you authenticate the user. If all is ok then you have an active session and can add stuff to it.

Now, having stated that. I do not use lassos built in session handler. Find it all to cumbersome. Instead I use my own.
https://gist.github.com/jolle-c/02b247b2468073608e17

Some examples on how to use it
On succesful login create the session using jc_session -> addsession

Then search for and add existing favourites.
jc_session -> data(’userfavs', #userfavmap)

If you on jq.lasso page want to add to the session.
jc_session -> data('userfavs’) -> insert(’newFavKey’ = #newFavValue)


There’s more to it, of course, but this is a hint of how to do it.

HDB
Jolle

> 27 sep. 2016 kl. 17:43 skrev Tom W Robinson <[hidden email]>:
>
> I'm using Lasso 9.3.1
>
> Thanks Jolle


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating SessionVariables using AJAX

Tom W Robinson
Thanks for your help Jolle!

I read a bit about your session handler, and the comment about being forced to use thread variables in Lasso's session handler, and it dawned on me that the issue I was having was that the use of the  $sessionVariable on the jq.lasso page had no reference that it was a SessionVariable so I could not manipulate the session.

I may start using your solution going forward, as it looks like a great alternative, but I wanted to post the solution for others.

In searching for a way to add to a sessionVariable, other than just using the thread variable name, I came across another Lassotalk post remarkably similar to mine back in 2006 titled "Session Var & AJAX Manipulation"...  not sure why my search terms didn't pick up on this 24 hours ago...

Anyways..

The key was to have a Session_Start statement on the jq.lasso page (Thanks Deco!).

This solved my current issue and also solved a previous issue I had with having to pass sessionVariables in the jquery .load method.  When placing the Session_Start on the jq.lasso file, all of the sessionVariables were now available to call.

Thanks again for pointing me in the right direction!
Loading...