0

I am trying to create a posting app but found

Parse error: syntax error, unexpected '$_SESSION' (T_VARIABLE) on line 5

Here is the part of code which give Parse error on line 5:

<?php

require "init.php"

$_SESSION["post"] = $_POST["data"];
$_SESSION["privacy"] = $_POST["privacy"];


//transfering to linkedin for authorization
header("location:",
"https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=".CLIENTID."&redirect_uri=".REDIRECTURI."&state=".CSRF."&scope=".SCOPES);


?>

Kindly have a look on it and guide me what mistake I did. Thanks

Amina Malik
  • 47
  • 2
  • 11

2 Answers2

1

you are missing the ';' in line 3

<?php

require "init.php";
//                ^ notice this is missed in your code
hassan
  • 7,812
  • 2
  • 25
  • 36
0

use session_start(); at the start of your code

<?php
session_start();
require "init.php"

$_SESSION["post"] = $_POST["data"];
$_SESSION["privacy"] = $_POST["privacy"];


//transfering to linkedin for authorization
header("location:",
"https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=".CLIENTID."&redirect_uri=".REDIRECTURI."&state=".CSRF."&scope=".SCOPES);


?>
RAUSHAN KUMAR
  • 5,846
  • 4
  • 34
  • 70