Enso Posted September 24, 2012 Share Posted September 24, 2012 Hi Everyone, I'm trying to get an audio file to play on a home page once per visit, but the problem I'm running into is that it plays *every* time a visitor goes to the home page. So, if a user goes to the home page, the file plays; then, if they go to another page on the website and return to the home page, the file plays again. Is there any way to get it to only play once per web browser session? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 24, 2012 Share Posted September 24, 2012 Let the user decide when to play it. No one likes video or audio that starts without them choosing to start it. Quote Link to comment Share on other sites More sharing options...
Enso Posted September 24, 2012 Author Share Posted September 24, 2012 I'm with you there. However, this is for a client, and they're pretty adamant about having it up. It's not *too* intrusive...it's just a 3-second welcome message. If it were me, there'd be no sound, but I have to go with the client's wishes. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 24, 2012 Share Posted September 24, 2012 Then store a variable in the session when they load the page. Quote Link to comment Share on other sites More sharing options...
krakjoe Posted September 24, 2012 Share Posted September 24, 2012 I know it's pretty difficult to get used too ... but look at it like this, if I hired a builder to make me a house, and I then requested them to do something that would threaten the integrity of it's structure I would not expect them to do it ... uncomfortable or not, it's a well known fact that people hate music playing or videos when they didn't request them, we have youtube for that. You should try a bit harder to impress the truth on your client in order to steer them from making the wrong decisions ... Why not show them a link to this page, experts in their field say it's the wrong thing to do, ergo, intrusive or not, it's the wrong thing to do. Just 2 cents, have fun Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 24, 2012 Share Posted September 24, 2012 Yeah you never *have* to go with what the client wants. They hire you for your skills and knowledge. Not as a slave. Quote Link to comment Share on other sites More sharing options...
premiso Posted September 24, 2012 Share Posted September 24, 2012 Not as a slave. I think most clients would rather have you as their slave Quote Link to comment Share on other sites More sharing options...
micah1701 Posted September 24, 2012 Share Posted September 24, 2012 (edited) Then store a variable in the session when they load the page. so something like: <?php if( !isset($_SESSION['audio_played'] || !$_SESSION['audio_played'])) { $_SESSION['audio_played'] = true; //set flag // code to play the dumb audio file goes here } ?> Edited September 24, 2012 by micah1701 Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 24, 2012 Share Posted September 24, 2012 (edited) You don't even have to check, just set it. Edit: For the code to play it, yes, you have to check. So looks fine to me. don't forget the session_start(); Edited September 24, 2012 by Jessica Quote Link to comment Share on other sites More sharing options...
Enso Posted October 2, 2012 Author Share Posted October 2, 2012 Thanks for all the help! Micah, thank you for your suggestion -- I tried the format that you provided, and it worked! Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted October 2, 2012 Share Posted October 2, 2012 I know the thread is is closed, but wouldn't a cookie be a better choice? You can set it to expire when the browser closes, and you wouldn't have to store the session information on your end. Quote Link to comment 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.