tamumech Posted July 5, 2007 Share Posted July 5, 2007 Hi, I am trying to implement a token identifier with a session. Can anyone explain to me how store it in the session data and use in get or post requests? Thanks -Tim Link to comment https://forums.phpfreaks.com/topic/58558-solved-simple-question-about-sessions/ Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 To store a value in a session use... <?php session_start(); $_SESSION['var'] = 'foo'; ?> then.. to retrieve it... <?php session_start(); $var = $_SESSION['var']; echo $var; ?> Pretty straight forward stuff. Link to comment https://forums.phpfreaks.com/topic/58558-solved-simple-question-about-sessions/#findComment-290481 Share on other sites More sharing options...
tamumech Posted July 5, 2007 Author Share Posted July 5, 2007 I understand how to store session data, but how do I use it in GET or POST requests? I am actually trying to store something in the URL, and something in a session cookie. Is there a way to do that without a form appearing on the page? Thanks Link to comment https://forums.phpfreaks.com/topic/58558-solved-simple-question-about-sessions/#findComment-290500 Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 <?php session_start(); $_SESSION['var'] = 'foo'; echo "<a href=\"link.php?var={$_SESSION['var']}\">link</a>"; ?> Link to comment https://forums.phpfreaks.com/topic/58558-solved-simple-question-about-sessions/#findComment-290509 Share on other sites More sharing options...
AbydosGater Posted July 5, 2007 Share Posted July 5, 2007 What do you mean? For example you want to link someone to a page, that needs their userID to display user information about them? <?php session_start(); $userID = $_SESSION['userID']; echo '<a href="information.php?userID='.$userID.'">View Your Info</a>'; ?> Andy Edit: Sorry Thorpe got there before me! Link to comment https://forums.phpfreaks.com/topic/58558-solved-simple-question-about-sessions/#findComment-290535 Share on other sites More sharing options...
tamumech Posted July 5, 2007 Author Share Posted July 5, 2007 Alright, do I have to do that on every hyper link on the page. Good times. Thanks fellas. Link to comment https://forums.phpfreaks.com/topic/58558-solved-simple-question-about-sessions/#findComment-290554 Share on other sites More sharing options...
AbydosGater Posted July 5, 2007 Share Posted July 5, 2007 Glad we could help Andy Link to comment https://forums.phpfreaks.com/topic/58558-solved-simple-question-about-sessions/#findComment-290691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.