How to display session message

hello sir
how to display session message after form submit?

my controller:-
public function Login($data, $form)
{
$form->sessionMessage('Thanks for your comment! ’ , ‘good’);
}

and in my template.ss:-

$good

thanks in advance

If that function is your form handler, then all you need to do is redirect back to the form after you’ve set the session message with return $this->redirectBack();

(Take a look here for an example: https://docs.silverstripe.org/en/4/developer_guides/forms/introduction/#creating-a-form)

this is my custom form in login.ss:-

<form class="form-signin" $LoginForm.FormAttributes>
               
                <h2 class="form-signin-heading">sign in </h2>
                <label style="margin-top: 10px;">Email</label>
                <input type="text" name="email" value="" id="username" class="form-control" placeholder="Please Enter your Email">
                <label style="margin-top: 10px;">Password</label>
                <input type="password" name="password" value="" id="password" class="form-control" placeholder="Please Enter your password">
                <div class="form-group">
                    <label class="checkbox">
                        <span class="pull-right">
                            <a  onclick=""> Forgot Password?</a>
                        </span>
                    </label>
                </div>

                <div class="form-group">
                     $LoginForm.Fields
                    <div class="registration">
                        Don't have an account yet? <a class="" href=""> Create an account
                        </a>
                    </div>
                </div>
                 <input type="hidden" value="{$AbsoluteLink}" name="redirectURL" />
            </form>

and this is my logincontroller
<?php

use SilverStripe\Control\Controller;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\EmailField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\Form;
use SilverStripe\Control\Session;
class LoginPage extends Page {
 
}


class LoginPage_Controller extends PageController {
	 private static $allowed_actions = ['LoginForm','Login'];
	 public function LoginForm(){
		    $form = Form::create(
            $this,
            'LoginForm'
        );
        $actions = new FieldList(
            FormAction::create('Login', 'Login')->setAttribute('class', 'btn btn-success')
        );

        $form = new Form($this, 'LoginForm',$actions);
        return $form;
	}

    public function Login($data, $form)
    {
    	$connect = mysqli_connect('localhost','root','','suitcrm');
        if(!$connect){ die('unable to connect'); }

        $email = $data['email'];
        $password = md5($data['password']);
        $sql = "SELECT * FROM contacts_cstm where email_c='{$email}' && password_c='{$password}'";
        $result = mysqli_query($connect,$sql);
        if(mysqli_num_rows($result) > 0){
            
            
            $form->sessionMessage('success','msg');
             return $this->redirectBack();
        }else{
            $form->sessionMessage('Incorrect username or password','msg');
             return $this->redirectBack();
          
        }
 
    }



}
?>

now how to display message after submit form??

can you help me please

thanks