How to pass variable session in an input of type hidden in php

0

I have a form and I need to pass the session value via post method. I'm using the code below, but it's not working.

<input type="hidden"  name="cod_usuario" value="<?php session_start(); $_SESSION['login']; ?>" class="input-medium" id="txtFuncionario" title="Nome do Funcionário"/>
    
asked by anonymous 03.09.2014 / 16:08

1 answer

1

First place at the beginning of your file.

<?php
session_start();
?>

Second, even though it is a session variable, to be populated in a form field, it is necessary to give ECHO to it. In your case:

<input type="hidden" id="txtFuncionario" 
name="cod_usuario" value=" <?php echo $_SESSION['login']; ?>" >
    
03.09.2014 / 16:40