Hi all,
I need to set a session variable based on what button is pressed in the submitting form. I have used the code below, but when I check for the variable in the next form as a test, it is empty. Why?
BTW, the button name is not an issue as I use similar code to redirect and this works fine.
aj
I need to set a session variable based on what button is pressed in the submitting form. I have used the code below, but when I check for the variable in the next form as a test, it is empty. Why?
BTW, the button name is not an issue as I use similar code to redirect and this works fine.
aj
<?php
$action = JRequest::getString('rf1sBtn');
$session =& JFactory::getSession();
if (strcasecmp($action, 'Yes') != 0)
{
$session->set('sessionchangedDetails', 'yes');
}
else
{
$session->set('sessionchangedDetails', 'no');
}
?>
Hi ajw3208,
I don't know why this should be unless the default values are being cleared by Joomla somewhere. Try declaring your own namespace in the Session and see if this helps
Bob
I don't know why this should be unless the default values are being cleared by Joomla somewhere. Try declaring your own namespace in the Session and see if this helps
$session->set('sessionchangedDetails', 'yes', 'my_name_space');
Bob
Hi Bob,
can do, but do you retrieve it as in the code below?
aj
can do, but do you retrieve it as in the code below?
$value= $session->get('sessionchangedDetails', 'my_name_space');
aj
Hi aj,
It's slightly different
See here for the full syntax.
Bob
It's slightly different
$value= $session->get('sessionchangedDetails', 'default_value', 'my_name_space');
See here for the full syntax.
Bob
Hi Bob,
Sadly no joy. It looks as if creating a sess variable in that place in CF doesn't work. Be interested to know if Max has any view on why.
I'l have to resort to an option tag (radio or drop) to allow this to be passed in the POST array. not ideal but.....
thanks anyway
aj
Sadly no joy. It looks as if creating a sess variable in that place in CF doesn't work. Be interested to know if Max has any view on why.
I'l have to resort to an option tag (radio or drop) to allow this to be passed in the POST array. not ideal but.....
thanks anyway
aj
Hi aj,
Odd - ChronoForms is using the session data OK - usually anyhow. I don't understand why it isn't saving for you. (You could try a cookie instead.)
What are you trying to achieve here - maybe there is another way?
Bob
Odd - ChronoForms is using the session data OK - usually anyhow. I don't understand why it isn't saving for you. (You could try a cookie instead.)
What are you trying to achieve here - maybe there is another way?
Bob
Hi Bob,
I need to maintain a status throughout a session, and the easiest user input mechanism to set the status via a yes no button selection. (my user community is not real bright so the buttons have to be big. option boxes mean too much thinking) :wink:
I ended up adding the required status yes/no to the URL as GET parameter. the full url string being determined by which button got pressed and this test is performed in the email after submit code box.
I then recover the GET value in the next form and then assign the value to the necessary session variable. a bit messier, but effective.
a real weird one huh!
As always, thanks for the help.
aj
I need to maintain a status throughout a session, and the easiest user input mechanism to set the status via a yes no button selection. (my user community is not real bright so the buttons have to be big. option boxes mean too much thinking) :wink:
I ended up adding the required status yes/no to the URL as GET parameter. the full url string being determined by which button got pressed and this test is performed in the email after submit code box.
I then recover the GET value in the next form and then assign the value to the necessary session variable. a bit messier, but effective.
a real weird one huh!
As always, thanks for the help.
aj
This topic is locked and no more replies can be posted.