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 ? Link to comment https://forums.phpfreaks.com/topic/132901-how-to-make-every-other-click-on-a-link-display-a-different-link/ 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"; ?> Link to comment https://forums.phpfreaks.com/topic/132901-how-to-make-every-other-click-on-a-link-display-a-different-link/#findComment-691074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.