I currently have this :
require_once(‘auth.php’);
auth.php:
session_start();
if(!isset($_SESSION['SESS_MERCHANT_ID']) || (trim($_SESSION['SESS_MERCHANT_ID']) == '')) {
header("location: login-form.php");
exit();
}
mybadges.php:
$mybadges = mysql_query("SELECT badge_id
FROM badges WHERE merchant_id = $current_userid ORDER BY badge_id DESC");
while ($result = mysql_fetch_array($mybadges)){
$badge_id = $result['badge_id'];
}
I wanted to know how I can store $result['badge_id']; in a $_SESSION array (like $_SESSION['badges']?)
a more sensible version of ‘auth.php’
a more sensible version of mybadges.php:
in case there is only one bagde_id to store:
in case there are many id’s (as one cannot say for sure from your code, what you need):
in general, to store anything an a session, just assign that anything to a session variable:
not a big deal.
a SESSION array become exectly what you wrote.
$_SESSION['badges']is a regular variable to use.Note that you can save only scalars, arrays and objects. Not resources.