Jump to content
washingtonalves

Passar uma $_SESSION PHP para uma VAR do JavaScript

Recommended Posts

Em 23/07/2019 at 11:54, washingtonalves disse:

Olá... ainda sou iniciante... alguem sabe me responder se tem como pegar um $_SESSION do php e colocar dentro de uma variavel do javascript?

 

Assim ?

 

<?php
 
session_start ();
 
$_SESSION ['qualquerCoisa'] = 'Programador';
 
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>PHP</title>
</head>
<body>
 
<script>
const umDadoQualquer = "<?php echo $_SESSION ['qualquerCoisa'] ?>"
 
console.log (umDadoQualquer)
</script>
</body>
</html>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.