Hello Bob/Admin
Can you send me an example of using code to add data fields to a session, say when a button is clicked, data in various fields on the form get sent to the session array ? And then code to display this data into a custom field?
Many thanks
Kind regards
Amelia
Can you send me an example of using code to add data fields to a session, say when a button is clicked, data in various fields on the form get sent to the session array ? And then code to display this data into a custom field?
Many thanks
Kind regards
Amelia
Can you send me an example of using code to add data fields to a session, say when a button is clicked, data in various fields on the form get sent to the session array ? And then code to display this data into a custom field?
I have managed to use PHP code to load and to get data from a session. Form example in a custom element I display the current session id and ip address of the user in this way:
<?php
$session =& JFactory::getSession();
echo 'Session id is: ' . $session->get( 'idsession', 'empty' );
echo 'Sessions ip address is: ' . $session->get( 'ipadd', 'empty' );
?>
and in Load CSS event I have:
<?php
session_start();
$session =& JFactory::getSession();
$idsession= $session->getId();
$ipadd = $_SERVER ['REMOTE_ADDR'];
$session->set( 'idsession',$idsession);
$session->set( 'ipadd',$ipadd);
?>
What I do not get is how to add data to a session when a button is clicked (but this button should not be a submit one but should keep the user on the same page). Say I have a textbox and after I fill it in by clicking a button this value gets put into a variable of the current session.
I hope this makes sense.
Thank you
Amelia
Hi Amelia,
You can write jQuery code to fire when the text is changed or a button is clicked, that code should do an AJAX call to a new form event with your session code.
Regards,
Max
You can write jQuery code to fire when the text is changed or a button is clicked, that code should do an AJAX call to a new form event with your session code.
Regards,
Max
This topic is locked and no more replies can be posted.