php – How to transfer session after being redirected to other page

Question

I am trying to display inputted fields on another page using sessions:

On page success of submitting information:

$username = sanitize_text_field( $_POST['username'] );
$user_login_username = $wpdb->get_var("SELECT username FROM login_first WHERE username="$username"");
echo "Welcome back . $user_login_username";
session_start();
$_SESION['username'] = $user_login_username;
//yes is value that displays content on next page
wp_redirect("https://mwcti.com/test-page/?success=yes");

Results after being taken to other page:

if("yes" == $_GET['success']) 
{
    session_start();
    echo $_SESSION['username'];
    session_destroy();
}

Any help would be greatly appreciated

0
John Lyons 4 weeks 2022-11-04T13:25:45-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse