Fredrik.r Posted November 17, 2006 Posted November 17, 2006 Hi, I use a gif and an animated gif in my shop that is supposed to be controlled by a session (on/off). I want it to remember if it should show the gif or the animated gif when visiting the shop. It works great outside the shop but when implementing it doesnt work at all. I have implemented the php code in my sts_template.html (yes, it can handle php). I have no idea why it doesnt work, has it got to do with other sessions that make this one not working? Please have a look below. Code in sts_template.php Before everything else <?php session_start(); ?> <?php if(isset($_SESSION['musicsession'])){ ?> <img src="http://www.domain.com/eu/images/site/music_on.gif" width="138" height="129" name="music"> <?php }else{ ?> <img src="http://www.domain.com/eu/images/site/music_off.gif" width="138" height="129" name="music"> <?php } ?> Code in file which starts the session (popup with music) <?php session_start(); ?> <?php $_SESSION['musicsession']= true; ?> Code in file which stops the session (popup) <?php session_start(); ?> <?php unset($_SESSION['musicsession']); ?> Again, this is working fine when not using it in osCommerce.
Guest Posted November 17, 2006 Posted November 17, 2006 Perhaps you should register into the osCommerce session: tep_session_register('musicsession'); and unregister: tep_session_unregister('musicsession'); You also have (eg.): if (tep_session_is_registered('musicsession')) { <do stuff> } Sonia
Fredrik.r Posted November 17, 2006 Author Posted November 17, 2006 Thanks for aswering Sonia! I am not sure I fully understand. Could you give me an example?
Guest Posted November 17, 2006 Posted November 17, 2006 From what you posted above: change: <?php session_start(); ?> <?php $_SESSION['musicsession']= true; ?> to: <?php $musicsession = true; tep_session_register('musicsession'); ?> and: <?php if(isset($_SESSION['musicsession'])){ ?> <img src="http://www.domain.com/eu/images/site/music_on.gif" width="138" height="129" name="music"> <?php }else{ ?> <img src="http://www.domain.com/eu/images/site/music_off.gif" width="138" height="129" name="music"> <?php } ?> to: <?php if(tep_session_is_registered('musicsession')){ ?> <img src="http://www.domain.com/eu/images/site/music_on.gif" width="138" height="129" name="music"> <?php }else{ ?> <img src="http://www.domain.com/eu/images/site/music_off.gif" width="138" height="129" name="music"> <?php } ?> and: <?php session_start(); ?> <?php unset($_SESSION['musicsession']); ?> to: tep_session_unregister('musicsession'); You can also use: if ($musicsession == true) { <do stuff> } Sonia
Fredrik.r Posted November 17, 2006 Author Posted November 17, 2006 Thanks!! :) I got an error when changing in the start session file; Fatal error: Call to undefined function: tep_session_register() in /home/skankse/public_html/eu/player/feelgood2.php on line 2
Guest Posted November 17, 2006 Posted November 17, 2006 Well... I guess its an STS thing, which I am not familiar with. For a file to use osCommerce classes and functions, it must make a call to application_top.php at the top of the file: require('includes/application_top.php'); Sonia
Recommended Posts
Archived
This topic is now archived and is closed to further replies.