New here. Frustrated. Searched and found helpful information. Tired stuff. Called Yahoo support and they couldn't help.
I have a sequence of 3 pages:
User fills in information, clicks button, post is used to send it to the next page.
I grab the user info and store it in a session array and display it. User confirms it is OK and clicks the next button
I use sessions to retrieve the data and process it.
Pages 2 and 3 have the session_start(); line in it at the beginning of the php script.
I checked the tmp file on the server and after page 2 loads a session file containing about 400 bytes shows up on the server. 400 bytes is about right.
Once page 3 displays I see a second session file in the tmp folder. It contains 0 bytes. Also, the session info does not seem to be picked up by this page.
I put a print_r ($_SESSION); line in the body of pages 2 and 3. On page 2 the correct data are displayed. On page 3 I just get "array = ()". The session array is empty.
Is it possible you are bumping to different domains (i.e. www.domain.com vs domain.com) between page loads? Are you getting any errors? Barring those two we might need to see some code.
<head>
.
.
<?php
//****** Main section ***************************************************************
// Here we pick up the data sent via post, then we clean it up and store it as part
// of the user's session.
//****** Main section ***************************************************************
// Here we pick up the data sent via post, then we clean it up and store it as part
// of the user's session.
// Get the value from each string.
$dw_Status[0] = substr($dw_Status[0],strpos($dw_Status[0],": ")+2);
$dw_Status[1] = substr($dw_Status[1],strpos($dw_Status[1],": ")+2);
$dw_Status[2] = substr($dw_Status[2],strpos($dw_Status[2],": ")+2);
$dw_Status[3] = substr($dw_Status[3],strpos($dw_Status[3],": ")+2);
}
For this guy it was set to an old domain. I don't think I have access to this file via Yahoo Web Hosting.
5. "Internet Explorer just refused to store my cookies, while other browsers are fine. I found a post stating that if you have an underscore in your url things can go mad in IE, it just refuses. I had an underscore in my url which was resolved by removing the underscore from my domain name. This cost me a day of investigation, so I hope this saves some of you some time."
6. Another server-side solution: "I thought I had solved this already with the .htaccess method described earlier. Alas, I found out that my hosting provider uses FCGI interface to run PHP on top of Apache, instead of mod_php that would have complied. It took me a good half a year to try the fix they provided - lo and behold, now it works! I remind you that I encountered the problem only with the hosting provider. Locally (Win XP) the sessions work as they should be. Here's how I did it (only applicable with my host):" Source: http://forum.symfony-project.org/vie...p?f=22&t=30214
7. "I changed the value for $config[‘cookie_prefix’] and now everything is working fine."
8. Third party cookies are enabled on my PC. Is it possible that the cookie expires before I get to use it again, a few seconds later?
9. "Long story short, when I redirected with a forward-slash "/" AFTER the .php, the page would create a different session ID than the rest of my domain was using."
10. This was mentioned - "What I realized was that the URL was changing from www.coryforsyth.com to coryforsyth.com. When the presence of the WWW changed, PHP thought it was a different session and created an empty one that caused my script to log me out. If I went to the location bar of my browser and added/removed the WWW (to the way it had been before), all was well and I was still logged in."
11. Another IE issue: "You can lose the session however if the the page contains a reference to <img src=""> with name and id references (which may be used if the image is referencing a dynamic image, called by javascript) This seems to cause IE6 to refresh the page session id and hence loose the session."
Do you have error reporting on? If so, maybe you can share any errors that are displayed or found in the log? A lot of times PHP will try to tell you when there is a session instantiation problem.
Maybe. I am not sure. How's that for a confidence builder?
I don't have php or and and server software on my PC. I've never written server or even database apps before. I ftp my php files to my Yahoo-hosted site and test them there.
I've seen the access log folder and looked at the most recent log. It's difficult to find any mention of errors in that. There has to be an error log somewhere.
This is my first ever php project. Last week was my first JavaScript project. I'm learning this all on my own at home using resources available on the Internet. It's working out for the most part, although I can get really stuck at times.
My last post was my collection of all the things I found that can cause the problem I was (Yes, was.) having. A lot of people have spent a lot of time on this type of problem and often the problem is on the server side, which I do not have access to.
Late last night I was about to give up and go back to using cookies. That's how I was doing this when I started this project. I was also starting to think about finding another hosting service. Then... it started working. I don't know how or why, but it just started working. That's good in a sense, because it is working, but bad because I didn't learn anything and I may end up dealing with this again.
I had tired a number of the things suggested on other forums, and here, and none seemed to work, but somehow, now it all does.
My programming background is mostly in Delphi and I have done a fair bit of desktop app development using it. I'm finding JS and php odd in how loose these seem to be, as in declaring variables and variable types, and also how tight in that both are case sensitive. And I often find myself typing = instead of == in IF statements, for example, so acclimating to the php language itself has gone slower than I expected. That's why I held off forever before joining a forum to ask for help, because such minor typos can cause me trouble and I can't go around asking people for help with that. I suspect I corrected such a typo and now things are working, and that really bugs me.
In my JS project I started using try/catch early to tell me what my errors were and that helped greatly. I have this in php now but had not fully implemented it, and now that I have I'm still not seeing my errors. I guess the server gets them all.
Thanks for the support and for providing a place to vent.
On a side note, if you are planning to do any further development in PHP a good idea is to install a localhost server to do your development on. That way you can make sure something is working and isn't an environment problem.
Wamp is probably the easiest way to get a localhost up and running in windows.
The problem has returned, but not on my current machine.
The project was nearly done and I was doing a lot of final testing, then switched to using my other PC to test from there. On that machine the session array is cleared on when I navigate between pages.
If it works on one PC but not another I don't see how it can be a server problem.
My first machine is running Windows 7 and I am using FireFox. The second machine is running XP Pro and I get the same problems with FireFox (14.01) and IE.
I checked security settings and turned off ad-blocker and other stuff. I've got the same antivirus software on both machines, eset. I cleared the cookies for this site and I set the security settings for FF to the same as on my first machine. I cleared all of the session files on the web server.
Still, the SESSION data is being lost when I navigate between pages, but only on the XP machine.
I worked until past 3 AM on this last night. It's very frustrating. Got some sleep and it didn't fix itself over night.
Other things read and tried or not applicable here.
1. Underscores in file names messes up IE and dumps the session. I checked and I did use underscores in three "include" files. Fixed that and a previously ignored error showed up, using the same name for a function in two different "include" files. Fixed all that but my sessions are still being dropped.
2. Cookies size is reportedly a problem. My session data is only 100-200 bytes. The second machine does have a lot of cookies stored by the browser but that can't be what they mean.
3. W3Schools says that the session_start command should go before the <html> tag. I moved it. No change.
4. One person solved their problem by using the following:
Bookmarks