I think wp_login
is executing before functions.php is actually opened, thus not setting the global variable. One possible solution to this is instead append to the URL:
function open_menu($user_login) {
wp_redirect(home_url().'?menu_open=true');
exit;
}
add_action('wp_login', 'open_menu');
Then you could get that value via
if(isset($_GET['menu_open']) && $_GET['menu_open'])