I've the php code as below. The variable $_SESSION['url']
has value and printing as it is. Its not working if I called the session variable.
session_start();
header('Content-type: application/pdf');
readfile($_SESSION['url']);
But Its working, If we wrote as below.
session_start();
$_SESSION['url']= 'http://samplepdf.com/sample.pdf';
header('Content-type: application/pdf');
readfile($_SESSION['url']);
if anybody experienced this, how to solve this? Thanks in advance
The $_SESSION
is variable (almost) like any other for duration of the script. So if you write it on one line of the script, you can read it later. No matter if sessions work or not in your environment.
So it's not surprising that your second example works. And it does not show anything that could help explaining your problem.
You should show us instead, what did you try to do to make sessions working. And where and how do you actually set the url
session variable?