I have written out a script that let's you define a session variable called "colors". Once it is defined and you close the page and then go back to it, it is suppose to remember and tell you the color you have set. But it is not doing that.
Here is my html and php code.
Here is the actual page.
When you first visit this url, you are suppose to type in a color or whatever you want to type in. When you close the window and go back to the same url, it isn't suppose to give you that text box. It is suppose to remember the $_SESSION['color'] variable and simply print that out . I can't figure out why it's not doing this. It's like a new session starts. Why isn't my preveious session variable maintained? I think it has to do with the fact that the PHP is embedded in HTML, because when I have another script that did work and that one has only PHP codes and no HTML
Why isn't the session maintained?
Started by acrionx, Oct 11 2010 05:02 PM
2 replies to this topic
#1
Posted 11 October 2010 - 05:02 PM
|
|
|
#2
Posted 11 October 2010 - 07:04 PM
session_start() calls an HTTP header to the client, thus it must be run before any content is sent out (incliding whitespace). Place it at the top if you script, i.e.
<?php session_start();?>Also note you output the HTML form regardless of it the session element is present or not.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#3
Posted 12 October 2010 - 12:05 PM


Sign In
Create Account

Back to top









