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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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>"; ?> Quote Link to comment 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! Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
AbydosGater Posted July 5, 2007 Share Posted July 5, 2007 Glad we could help Andy 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.