jjk2 Posted November 16, 2008 Share Posted November 16, 2008 lets say i have a link. i want it to display 2 URLS. if i click it once, it will display google.com if i click it the second time, it will display yahoo.com how can i do this using cookie sessions ? Quote Link to comment Share on other sites More sharing options...
marcus Posted November 16, 2008 Share Posted November 16, 2008 <?php session_start(); print_r($_SESSION); if($_SESSION['clicks'] >= 0){ $_SESSION['clicks'] += 1; }else { $_SESSION['clicks'] = 0; } $urls = array(0 => 'http://google.com', 1 => 'http://yahoo.com', 2 => 'http://msn.com', 3 => 'http://omgpie.com'); echo "<a href=\"".$urls[$_SESSION['clicks']]."\">".$urls[$_SESSION['clicks']]."</a>\n"; ?> 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.