Php session expires always when some image is not loaded on my site

For anyone to be able to help, you will need to post all of the code from the affected page.

Perhaps PHP error_reporting(0); is set which will prevent ALL errors from being reported.

Try adding these lines to the start of the file to TEMPORARILY force errors to be shown:

ini_set('display_errors', 'TRUE'); // SHOW ERRORS ON THE SCREEN
ini_set('error_log', 'ERROR_LOG.php'); // 

I think that will TEMPORARILY need the file permissions t be set to 0777

@Dj_daki: when you post code on the forums, you need to format it so it will display correctly.

You can highlight your code, then use the </> button in the editor window, or you can place three backticks ``` (top left key on US/UK keyboards) on a line above your code, and three on a line below your code. I find this approach easier, but unfortunately some European and other keyboards don’t have that character.

(I edited your post above for you.)

The Point of showing code is to see where your problem might be with regards to session and how links or images might interfere with session. You posted a small <img line, which I suppose might make us ask, “Do you have an image called image.jpeg?” but it doesn’t really help us spot the problem you are describing.

I don’t have that image because I deleted it but it remained in the mysql database link to it, I don’t know how it makes a problem for the session?

It does not. There is nothing with this image or any other that is missing that can affect the sessions.

This has been stated multiple times above in the post, and if you want help you need to show your code. In the event you don’t, I expect you’re just trolling.

ok, I’ll solve this by putting a default image for deleted images, otherwise I don’t see a solution, I showed you the code I use for images so thank you all for the tips :+1:

Well I did suggest you use a default image is the file doesn’t exist from my POST #5 so the page is not throwing errors to the browser. You did not upload a file or supply us your page code showing where you start the session, or how links are defined as you did say when I click a link there is a problem, or show use dynamic coding of how images are displayed. You only showed a hard coded line of code to show image.jpeg and so the question was put to you, DO you have an image.jpeg as a default image. If not then you are just hard coding errors to the page.

As you have given us nothing I assume you building content within a while loop.
Define your default image and check if the database defined image exists within this while loop and set an image variable to that image or the default. Note: I understand you have more display code but just show this part.

$DefaultImage = "DefaultImage.jpeg";
while($row = $result->fetch_assoc()){

	$MyImage = (file_exists("imagefolder/".$row['image']) ? $row['image'] : $DefaultImage); 
	echo '<br/><img src="imagefolder/'.$MyImage.'" alt="icon" height="250" width="200" />';

This should at least get rid of the “no image” error. That being said, this has nothing to do with destroying a session. If something is sent to the browser (like an error) before session_start(); is called then you can’t read any sessions. As mentioned many times this is most likely the problem. As an example:

include 'header.php';

… is going to be a problem as <html> has been sent to the browser before session is started. An error being thrown to the browser can affect session start in the same way.
Write code that can HANDLE errors (like missing images) so no errors are sent to the page.

I just made a new file to test the logout of the session and I noticed only one problem, there is a problem that the session always logs off when the img tag is a link to the image in my folders and if the img src path does not have my address but someone else’s, it doesn’t matter there is an image with someone else’s link, then the session works normally, only with my paths to the image the session is logged out if the image is deleted, very strange

Maybe you could share this file. It sounds like a very strange setup to be linking to an image path with a link regardless of who the image belongs to. Or are you working with a directory structure for each user. If that’s the case you should define images with absolute paths.