简体   繁体   中英

Joomla - Create session variable from checkbox with ajax

I'm trying to create a session variable joomla style with ajax when checkboxes are selected. Here is my code in the select_thumb.ajax.php file:

$_SESSION['ss'] = $value;
$response = $_SESSION['ss'];
echo $response;

}
exit;
// Get db connection
$db = JFactory::getDbo();
//create new query object
$query = $db->getQuery(true);

//Prepare insert query
$query
    ->insert($db->valueChbx('download_variable'))

// Set the query using populated query object and execute it.
$db->setQuery($query);
$db->execute();
?>

Here is my HTML for the checkboxes:

<input type="checkbox" id="thumbselect" name="valueChbx" class="checkbox" value="/import/images/'+data[i]['filename']+'">';

I haven't coded the ajax through javascript yet because I'm wondering if i should use onFocus? There could be multiple checkboxes selected. Thanks for any help in advance.

Do not use PHP's default session variable in Joomla application use its native factory for that.

Set a session variable

$session = JFactory::getSession();
$session->set('name', "value");

Get a session variable

$session = JFactory::getSession();
echo $session->get('name');

more .

hope it helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM