Forum Moderators: coopster
Now, however, I have started to mess with ajax calls to other php pages that do some of the form processing, and I am having some trouble accessing the session variables. I am simply trying to set session variables in the ajax php pages and then access them back in the main php pages.
I tested it for a while and first came to the conclusion that I just couldn't get the session variables to set or access them if I set them in the ajax php files. However I finally figured out that they weren't setting in the ajax php files because I hadn't redeclared session_start in that page. So, when I redeclare that method, I can set the variable and I can then load one of the main pages and I can access the variable. However, now I have a new problem in that I am declaring this second session_start from an ajax call after the main page has already been sent to the browser and so I get header errors saying content has already been sent. So, I am stuck. If I don't call the second session_start, I don't have access the variables. If I do, I get header errors.
Does this make sense? Please help.
Then you can include this on your ajax page(s) with the same settings.
e.g. I ajax/jquery $.get to a page which has that include on and it works fine
Also make sure your session lasts (not just session_start)
$expireTime = 60*60*24*3; // 3 days
session_set_cookie_params($expireTime);
session_start();