Kulak Posted March 8, 2007 Share Posted March 8, 2007 Hi, I have included some variables in my code that I want to be passed from page to page, I wrote the code and everything seemed to be working until I tried my pages from my workplace and discovered that the values weren't being passed. I tried lowering the internet security and allowing cookies and it was fixed. How do I write my code so that all ie sessions will allow the values to be retained? Thanks Link to comment https://forums.phpfreaks.com/topic/41839-using-_session/ Share on other sites More sharing options...
pocobueno1388 Posted March 8, 2007 Share Posted March 8, 2007 You can pass values through hidden forms, that might be easier. If you are trying to store a value in a session, remember that you must call session_start() at the top of each script or the session will die. Here is an example of setting a session. $_SESSION['whatever'] = 10; Is that how you are doing it? Link to comment https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202894 Share on other sites More sharing options...
Kulak Posted March 8, 2007 Author Share Posted March 8, 2007 session_start() is at the top of each page. I haven't heard of hidden forms, i'll look them up. Thanks Link to comment https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202898 Share on other sites More sharing options...
pocobueno1388 Posted March 8, 2007 Share Posted March 8, 2007 Do you have a submit buttion? If you do you could make your script look something like this: <?php print<<<HERE <form action="wherever.php" method="POST"> //Hidden field that contains the value of $value <input type = "hidden" name="hidden_value" value="$value"> <input type="submit" name="submit"> </form> HERE; ?> Then to get the value of the hidden field on your next page, just call it like this: $value = $_POST['hidden_value']; Link to comment https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202903 Share on other sites More sharing options...
Kulak Posted March 8, 2007 Author Share Posted March 8, 2007 Here is what I have at the top of the page that I want to pass the variable to. <?php session_start(); ?> And then I put the value of $_SESSION['$WC'] into $words here: <?php $words=$_SESSION['$WC']; ?> Is this correct? Link to comment https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202930 Share on other sites More sharing options...
linuxdream Posted March 8, 2007 Share Posted March 8, 2007 By default, I believe PHP passes the session id as a cookie (your problem) but then tries to pass the session id in the URL if cookies are not enabled. Not sure why it wouldn't work, but you might want to check your server's php.ini config file to see if for some reason only cookie based session handling is being supported. Maybe you can enable session handling through the URL. Link to comment https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.