Topic awaiting preservation: Session Variables (Page 1 of 1) |
|
---|---|
Nervous Wreck (II) Inmate From: |
posted 01-30-2004 20:16
This as far as I know is a very basic question. I am developing a project with PHP and it is my first time using the language. I am having trouble seeing session variables on a different page to where they are declared. I start by saying session_start(); , then session_register("FirstName");, and then $_session["FirstName"] = $_POST['First_Name']; to take the value from a form. However when I go to the next page and try use this $_session["FirstName"] variable it holds no value. I am using session_start() again on the next page. I am missing something - as i said I have no real knowledge of PHP and I am finding it hard to get a proper session variables tutorial on the web. Can anyone help me out? |
Paranoid (IV) Inmate From: Sthlm, Sweden |
posted 01-30-2004 21:34
Personally I prefer to do these things like this: code: <?php session_start();
code: <?php session_start();
|
Nervous Wreck (II) Inmate From: |
posted 01-31-2004 14:34
For some reason this is just not working. Can anyone think of a reason why this would not be working. Do I have to specify somewhere how long I want the session variable to last or something. The code I was given above is exactly how I have it on my site. I am getting really annoyed and confused as I imagine things are bound to get harder but how do I proceed when I acnt get the session variable to save its value from just one page to the next. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 01-31-2004 16:33
Since session variables are stored on the server as opposed to being stored by the user, you might need to check with your web host to see if they are enabled. I would ask your host what the problem is and why the example code is not working. |
Nervous Wreck (II) Inmate From: |
posted 01-31-2004 16:39
thanks, i think that must be the problem. i am using a local apache server. if anyone knows anything about apache configuration i`d love it if ye could help me out. meantime I`m going to find an apache forum. |
Paranoid (IV) Inmate From: [s]underwater[/s] under-snow in Juneau |
posted 01-31-2004 19:40
Is ' session_start()' the very first line of code on your page? If you send anything to the browser before it it won't work....... |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 01-31-2004 20:06
The problem is: You haven't read the documentation properly . quote:
|
Nervous Wreck (II) Inmate From: |
posted 02-02-2004 15:12
Ya I saw that a few days back and changed it. Still no luck though. All my syntax is definitely right. I have tried putting the session_start(); at the start of the php script, i have tried putting it at the start of the html body in its own php tags, i have tried putting it in the head of the document. nothing works. still no values being saved when i go to the next page. I am looking into my php configuration being wrong somehow but its like looking for a needle in a haystack. any other suggestions would be greatly welcome. (I am using php_4.3.4, and apache_2.04.) |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 02-02-2004 16:12
have you turned on all error reporting with error_reporting(E_ALL) ? |
Nervous Wreck (II) Inmate From: |
posted 02-02-2004 22:22
Finally I have discovered the source of my problem. After searching hundreds of forums and reports on php, my answer came to me like an angel in the night. Tell the world: IF YOU ARE USING WINDOWS THEN YOU MUST CHANGE THE SESSION_SAVE_DATA VALUE TO C:/TEMP OR C:/WINDOWS/TEMP IN YOUR PHP.INI FILE. For the love of god why dont they say this on the php.net site (or was i just too blind to see it). But there it is, thank you all for your help and no doubt it wont be long before I return again. Adieu Adieu!! |