PDA

View Full Version : How to use sessions with scripts called from php_include


Aurous
04-28-2004, 05:30 PM
Hi

I have a banner rotation script that is called from php_include.

It works fine, but I would like the banners rotate only once every user session. How do I do this? Sorry, but I'm a n00b in php.

Please help.

Thanks

Aurous
04-29-2004, 05:54 AM
anyone?

NTLDR
04-29-2004, 06:04 AM
Please wait at least 24 hours before bumping posts :)

Aurous
04-29-2004, 06:14 AM
I was told 12 hrs at vBulletin.com

Now, .org has their own rules? Where can I read them bloody rules, so when I get a reply back in my thread, it is actually useful!

Thanks

Aurous
04-29-2004, 07:37 AM
Here's the simple script (banner.php) I made to rotate banners.


<?php
srand((float) microtime() * 10);

$input = array(
"<img src=\"$stylevar[imgdir_misc]/banner1.jpg\" width=\"480\" height=\"60\" />",
"<img src=\"$stylevar[imgdir_misc]/banner2.jpg\" width=\"480\" height=\"60\" />",
"<img src=\"$stylevar[imgdir_misc]/banner3.jpg\" width=\"480\" height=\"60\" />"
);

$rand_keys = array_rand($input, 3);

echo $input[$rand_keys[0]] . "\n";

?>


and this what I have in php_include:


ob_start();
include_once("banner.php");
$randomlogo = ob_get_contents();
ob_end_clean();


Now the question I have is what should I change in the script so it only run once every user session? Please help.

Thanks

Aurous

Aurous
04-29-2004, 09:47 AM
I just came up with an idea, but I have no clue how to implement this.

I can call the script mentioned above by a cron job every couple hrs, and make the output store in my database.

Then make another php script that will call the html tags in the database. I dont know if this is a very smart idea. If someone can come up with a better suggestion then please let me know.

Thanks

Aurous

Aurous
04-30-2004, 12:44 PM
anyone?

Aurous
05-02-2004, 02:25 AM
*bump*