Tuesday, September 23, 2008

Javascript popup with PHP Session

Simple to detect whether user is 1st time enter the website, the code below are example working code

if ($_SESSION['SID']['pop'] == '' || $_SESSION['SID']['pop'] == 0) echo 'window.onload=alert("Test, 1 popup for 1 session. By s4femod3")';
$_SESSION['SID']['pop'] += 1;
echo 'window.onload=alert("Test, 1 popup for 1 session. Current session val :'.$_SESSION['SID']['pop'].'")';

Everytime user refreshed the page the value $_SESSION['SID']['pop'] will increase by 1.


0 Comments:

Post a Comment

<< Home