Add Session Variable

Started by nclmccain, July 12, 2023, 03:10:11 AM

Previous topic - Next topic


I'm working on a project and I'm using the the SSI for user authentication and data. My question is usually when I code a form I'll restart the session and add a bit of data using the $_SESSION[] = data method. However since I'm using SMFs sessions I can't use my own sessions. How would I go about doing this using the existing sessions?

Thank you for the help.


Hi, the relevant code is
    // Set the randomly generated code.
    if (!isset($_SESSION['session_var']))
        $_SESSION['session_value'] = md5(session_id() . $smcFunc['random_int']());
        $_SESSION['session_var'] = substr(preg_replace('~^\d+~', '', sha1($smcFunc['random_int']() . session_id() . $smcFunc['random_int']())), 0, $smcFunc['random_int'](7, 12));
    $sc = $_SESSION['session_value'];

Is this a login form?


Not for a login but to insert information into a database and then to add a variable to the session and returned to the original page so a success message can be displayed.

I usually do something like:

if ($insert) {
$_SESSION['msg'] = 1;
// return to original page

if(!empty($_SESSION['msg'])) {
//message here