0

I am having huge problems with using echo in PHP. I thought that it is my mistake, so I went to w3schools to copy a simple line and paste it, but I still got "1 problem in this file"

The line I am trying is like that

        <?php
        if(isset($_SESSION["userid"])){
          
          echo "<p> Здравей, " . $_SESSION["userid"] ."</p>";
        ?>

I have also tried that line from w3schools which also seems to not be working

        <?php
        if(isset($_SESSION["userid"])){
          
          echo 'One line simple string.<br />';
        ?>

And basically every other I try is not working as well.

1 Answers1

1

For using session you have to start first session. Also you were missing closing if bracket.


<?php
session_start();
$_SESSION["userid"] = "testuser";
        if(isset($_SESSION["userid"])){
          
          echo "<p> Здравей, " . $_SESSION["userid"] ."</p>";
       }
        ?>
Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53