var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
session control and images in PHP
I was trying to build a mechanism that would prevent access to images if a session is not active. My plan was to write somthing echo the headers and the contents of the file unless a session var is not set:
However, I realized that once a $_SESSION var has been accessed, it is too late for sending the headers.
if(! $_SESSION [ 'mysession' ])
header ( 'Content-type: image/jpeg' );
header ( 'Content-Disposition: inline; filename="filename.jpg"' );
readfile ( $thefile );
Why is this so? Any ideas how I can solve this problem?
How about sending the headers first, then starting the session. If the correct session var isn't there, then just send out a 'no permission' image?
Thank for your answer. This works on my home computer (windows) but not on the server on which the script it supposed to run.