Jump to content

Modifying A Cookie From A Url


darkboost
 Share

Recommended Posts

I have 2 frames MAIN-PAGE and FOOTER and am only using frames to avoid page refreshes in the FOOTER which has many thumbnails. When the user clicks a thumbnail image I simply want the MAIN-PAGE to refresh with the correct image. Because of the limitations of frames and avoiding making a separate php page for each image I have started looking at cookies which from what I see looks ideal.I have set in index.php : setcookie("id", "1");and then echo this in the MAIN-PAGE and the image loads fine but am now wanting to know if I can and how can I update this cookie when a used clicks a thumbnail?Any assistance or suggestions on other ways to achieve this outcome would be greatly appreciated.

Link to comment
Share on other sites

This doesn't answer your question. Personally, I think you're working too hard.1. Images are normally cached by browsers. Even huge ones. Thumbnails should not be a problem. Meaning, after the first page load, your thumbs should load instantly, whether they are in a frame or not. If your user visits the page often enough, they will stay cached, and still load instantly. If load time is your issue, a frame is unneeded.2. If you don't want to hardcode your footer into every page, look into the PHP include statement. It sounds ideal for your application.

Link to comment
Share on other sites

I was originally using the PHP Include feature and loading the image based on the $_GET however it would always reset the the thumbnail scrolling which was very annoying if you had clicked image 350/1200 and then have to keep scrolling etc. I know there are many Javascripts available which write position cookies which sounds even more fullon than what I was simply trying to achieve which is to place the image number in the cookie and load the image from there.Can you update a cookie via a URL like the example below?

<?php$update_cookie = cookieset("id", "20");echo '<a href="index.php?id="20" target="main-page" '.$update_cookie.'><img src="../thumb/001.jpg" border="0" /></a>';?>

Link to comment
Share on other sites

Why not just use AJAX?Edit: the above code doesn't make sense - it will just echo out

<a href="index.php?id="20" target="main-page" return value of cookieset()><img src="../thumb/001.jpg" border="0" /></a>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...