Jump to content

Recommended Posts

Can anyone see why the link to the products page shown below would drop my SESSION? If I change the link to just products.php, the SESSION stays active. The way it is now, the SESSION is dropped (even though the link works fine). $root is defined as "" as this is on my home page. Also, I tried taking $root out and that didn't help. The only way to keep the SESSION alive is to change the link to href="../products/". There must be some sort of conflict with passing a variable in the URL?

 

	<?php			
		$sql = "SELECT * FROM product WHERE product_featured = 1";
		$result = mysql_query($sql) or die('<p>Unable to perform product query. Error: ' . mysql_error() . '</p>');

		while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			echo('<div class="product_mini"><a href="' . $root . 'products?prod_id=' . $row[prod_id] . '"><img class="product_thumb" src="' . $row[product_image] . '" /></a></div>');
		}
	?>

 

Thanks.

RyanOD

Link to comment
https://forums.phpfreaks.com/topic/51086-dropped-session-issue/
Share on other sites

OK, I fixed this ridiculous problem. I wanted to share the final result so as to save others from the same pain. Also, I don't understand why my solution worked. Hopefully, someone can enlighten me.

 

Initially, the product images on the home page were linked to the actual product pages as follows:

 

echo('<div class="product_mini"><a href="' . $root . 'products?prod_id=' . $row['prod_id'] . '"><img class="product_thumb" src="' . $row[product_image] . '" /></a></div>');

 

This approach ALWAYS dropped the $_SESSION. However, if I change it to the following (I put a forward slash after the directory name) it maintains the $_SESSION:

 

echo('<div class="product_mini"><a href="' . $root . 'products/?prod_id=' . $row['prod_id'] . '"><img class="product_thumb" src="' . $row[product_image] . '" /></a></div>');

 

Can anyone tell me why this happens? Maybe it has something to do with targeting the index.html file in a lower directory by just targeting the folder name?

 

RyanOD

Link to comment
https://forums.phpfreaks.com/topic/51086-dropped-session-issue/#findComment-251455
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.