php_guest Posted January 20, 2009 Share Posted January 20, 2009 Could you explain me if it is possible to pass value of session into variable or href? I tried following, but it doesn't work: page 1 <?php session_start(); $_SESSION['colour'] = "blue"; ?> page 2 <php session_start(); $_SESSTION['colour']= $colour; echo "<a href='page2.php/$colour'>$colour</a>"; or <php session_start(); echo "<a href='page2.php/$_SESSION['colour']'>$_SESSION['colour']</a>"; ?> Please tell me what is wrong with first one and second one? Link to comment https://forums.phpfreaks.com/topic/141664-solved-session/ Share on other sites More sharing options...
revraz Posted January 20, 2009 Share Posted January 20, 2009 page 2 <php session_start(); $colour = $_SESSTION['colour']; <----you had it backwards echo "<a href='page2.php/$colour'>$colour</a>"; ?> Link to comment https://forums.phpfreaks.com/topic/141664-solved-session/#findComment-741556 Share on other sites More sharing options...
php_guest Posted January 20, 2009 Author Share Posted January 20, 2009 thanks. Is there also any way to put value of session directly to href without moving value to variable, like I did it in the last option? Link to comment https://forums.phpfreaks.com/topic/141664-solved-session/#findComment-741640 Share on other sites More sharing options...
trq Posted January 20, 2009 Share Posted January 20, 2009 Yep. <?php session_start(); echo "<a href='page2.php/{$_SESSION['colour']}>{$_SESSION['colour']}</a>"; ?> Link to comment https://forums.phpfreaks.com/topic/141664-solved-session/#findComment-741641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.