jim.davidson Posted August 15, 2011 Share Posted August 15, 2011 I have some code that runs fine on one web site and I'm using the same code on another one. Example: if (!$error) { $_SESSION['number_drivers'] = $_POST['number_drivers']; $_SESSION['number_vehicles'] = $_POST['number_vehicles']; $_SESSION['current_insurance'] = $_POST['current_insurance']; $_SESSION['current_company'] = $_POST['current_company']; $_SESSION['refferal'] = $_POST['refferal']; session_write_close(); // go to step two header('Location: http://www.mywebsite.com/auto_quote2.php'); exit; } The sites are hosted by different companies. On site #1 everything runs just fine but on site #2 the saved session variables get lost. I notice when I ran phpinfo() on both of them that on site #1 the session.save_path is set at no value while on site #2 it is set as C:\WINDOWS\Temp Is this the reason I can't find the session variables on site #2 and if so how can I retrieve them? Any help will be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 15, 2011 Share Posted August 15, 2011 On both the page you posted the partial code for and the page you are redirecting too, add the following three lines of code immediately after the first opening <?php tag and tell us if there are any php errors reported when you try your code - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(-1); Also, is there any chance that you are redirecting back and forth between pages that have and don't have the www. on the URL? Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/#findComment-1257504 Share on other sites More sharing options...
ttocskcaj Posted August 15, 2011 Share Posted August 15, 2011 It sounds like your trying to move session variables between two different servers. Which I'm pretty sure you can't do. (Well very easily anyway) Better off using cookies. Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/#findComment-1257507 Share on other sites More sharing options...
jim.davidson Posted August 15, 2011 Author Share Posted August 15, 2011 For the first repy I made the changes an here is the only error I got Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for '-7.0/DST' instead in C:\Inetpub\vhosts\myinsuranceagency.com\httpdocs\my_copywrite.php on line 6 1966-2011 My Insurance Agency. All Rights Reserved For the second reply I might not have been clear, the pages auto_quote1.php and auto_quote2.php reside on two different domains running through different Hosting companes running identical code. I'm not trying to send from one domain to the other. It's just that it works fine on one but not the other auto_quote2.php uses session variables created in auto_quote1.php Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/#findComment-1257527 Share on other sites More sharing options...
PFMaBiSmAd Posted August 15, 2011 Share Posted August 15, 2011 If you didn't get any session_start related php errors, it is likely that the session is being started, assuming your session_start statement(s) are being executed in your code. Any chance you are using short open tags in some included files so that part of your php code is not being seen as being php code? Are you getting the PHPSESSID cookie in your browser? What about this question that was asked - Also, is there any chance that you are redirecting back and forth between pages that have and don't have the www. on the URL? Also, any chance that the path to the page with the code you posted is different than the path to the auto_quote2.php page you are redirecting to? Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/#findComment-1257533 Share on other sites More sharing options...
ttocskcaj Posted August 15, 2011 Share Posted August 15, 2011 My bad. header('Location: http://www.mywebsite.com/auto_quote2.php'); The fact that you have a full URL made me think you were redirecting for a second step or something. Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/#findComment-1257536 Share on other sites More sharing options...
jim.davidson Posted August 15, 2011 Author Share Posted August 15, 2011 session.name on both servers is set at PHPSESSID. The $10,000 question is..why does the code work just fine when running on server A but cannot find the session variables when running on server B? Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/#findComment-1257564 Share on other sites More sharing options...
PFMaBiSmAd Posted August 15, 2011 Share Posted August 15, 2011 No one here asked what the session.name is set to. However, someone has been asking you specific questions, twice for one of them, that would pin down what could be causing the problem. Without specific feedback from you to let us know what you are doing (urls/paths) and what part might be working (such as getting the session id cookie in your browser), no one here can help you. Quote Link to comment https://forums.phpfreaks.com/topic/244807-session-variables-lost/#findComment-1257566 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.