ryan.od Posted May 12, 2007 Share Posted May 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51086-dropped-session-issue/ Share on other sites More sharing options...
ryan.od Posted May 12, 2007 Author Share Posted May 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51086-dropped-session-issue/#findComment-251455 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.