Hiya,

Is this:

function unset_sessions()
{
    //All Sessions on the script ....
    UNSET($_SESSION['registration_form_display']);
    UNSET($_SESSION['registration_form_button_clicked']);
    UNSET($_SESSION['domain']); //Form Input
    UNSET($_SESSION['domain_email_account']); //Form Input
    UNSET($_SESSION['domain_email']); //Form Input
    UNSET($_SESSION['password']); //Form Input
    UNSET($_SESSION['errors']); Displays errors underneath the form.
    echo __LINE__; echo '<br>';//DELETE
}

unset_sessions();

the exact same as this:

session_destroy();

I ask, because sometimes the 1st one fails to unset or NULL the values of some sessions such as this:

$_SESSION['registration_form_display

And I have to destroy session. Shall I opt to destroy the sessions instead to wipe-out displaying on form previous form inputs ?

Why I created sessions for user inputs.
Let's say user filled-in 2 form fields correctly and missed 1 or input is wrong on one. When they hit the SUBMIT button, script displays errors and indicates what the error is on which particular field. But only after page reloads on submit button click.
So, if form not filled properly and submit button is clicked then form is reloaded on screen for user to correctly fill-in form before trying to submit again.
As for those fields filled correctly, clicking the submit button would delete the inputs and so I dump the inputs to the sessions and then on page load (after clicking submit button) I repopulate the input fields with their previously correct inputs.
That's why I use sessions on forms.
And yes, I do not dump passwords onto sessions or cookies.

Recommended Answers

All 3 Replies

Folks,

Are these 4 same:

1


function unset_sessions()
{
    $_SESSION['registration_form_display']='';
    $_SESSION['registration_form_button_clicked']='';
    $_SESSION['domain']='';
    $_SESSION['domain_email_account']='';
    $_SESSION['domain_email']='';
    $_SESSION['password']='';
    $_SESSION['errors']='';
}

2


function unset_sessions()
{
    $_SESSION['registration_form_display']=FALSE;
    $_SESSION['registration_form_button_clicked']=FALSE;
    $_SESSION['domain']=FALSE;
    $_SESSION['domain_email_account']=FALSE;
    $_SESSION['domain_email']=FALSE;
    $_SESSION['password']=FALSE;
    $_SESSION['errors']=FALSE;
}

3


function unset_sessions()
{
    $_SESSION['registration_form_display']=NULL;
    $_SESSION['registration_form_button_clicked']=NULL;
    $_SESSION['domain']=NULL;
    $_SESSION['domain_email_account']=NULL;
    $_SESSION['domain_email']=NULL;
    $_SESSION['password']=NULL;
    $_SESSION['errors']=NULL;
}

4


function unset_sessions()
{
    $_SESSION['registration_form_display']=0;
    $_SESSION['registration_form_button_clicked']=0;
    $_SESSION['domain']=0;
    $_SESSION['domain_email_account']=0;
    $_SESSION['domain_email']=0;
    $_SESSION['password']=0;
    $_SESSION['errors']=0;
}

Folks,

This does not really make sense now does it ?


function unset_sessions()
{
    $_SESSION['registration_form_display']=-1;
    $_SESSION['registration_form_button_clicked']=-1;
    $_SESSION['domain']=-1;
    $_SESSION['domain_email_account']=-1;
    $_SESSION['domain_email']=-1;
    $_SESSION['password']=-1;
    $_SESSION['errors']=-1;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.