Re: [PHP] session variable problem
On 3/25/2011 3:55 PM, Peter Lind wrote: More info (including some code) would be needed to get to the bottom of this, I'd say. Hard to diagnose what's happening otherwise. Regards Peter So I guess there is no list of things to check for sessions? I'll try to pair down the code to something postable, but it does work on the old server.let me see what I can come up with. -- Mark B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variable problem
call session_destroy(); then start the session again
[PHP] session variable problem
Very rusty with PHP. We moved our web site to a new hosting service (godaddy). PHP changed from 4x to 5.2.17. I can no longer change $_SESSION variables after the first use. First call to form - start session create variables Second call - can read variables, change existing ones (but they do not persist to next call) - cannot create new variable without an error Using $_SESSION['varname'] always session.auto_start off register_globals off session.use_only_cookies off I assume this is setting difference but I can't seem to find it. -- Mark B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variable problem
At 01:09 PM 3/25/2011, markb wrote: Very rusty with PHP. We moved our web site to a new hosting service (godaddy). PHP changed from 4x to 5.2.17. I can no longer change $_SESSION variables after the first use. First call to form - start session create variables Second call - can read variables, change existing ones (but they do not persist to next call) - cannot create new variable without an error What's the error you're getting? Also, do you have a call to session_start() at the beginning of each script before any output is sent to the browser? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variable problem
On 3/25/2011 12:13 PM, Ken Robinson wrote: At 01:09 PM 3/25/2011, markb wrote: Very rusty with PHP. We moved our web site to a new hosting service (godaddy). PHP changed from 4x to 5.2.17. I can no longer change $_SESSION variables after the first use. First call to form - start session create variables Second call - can read variables, change existing ones (but they do not persist to next call) - cannot create new variable without an error What's the error you're getting? Also, do you have a call to session_start() at the beginning of each script before any output is sent to the browser? Ken No error messages at all. error_reporting(E_ALL ^ E_NOTICE ); (I thought I was getting an error when creating new variables but that must have been a typo.) Session_start() called before any output (script was working on old host). -- Mark B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variable problem
On 3/25/2011 12:13 PM, Ken Robinson wrote: At 01:09 PM 3/25/2011, markb wrote: Very rusty with PHP. We moved our web site to a new hosting service (godaddy). PHP changed from 4x to 5.2.17. I can no longer change $_SESSION variables after the first use. First call to form - start session create variables Second call - can read variables, change existing ones (but they do not persist to next call) - cannot create new variable without an error What's the error you're getting? Also, do you have a call to session_start() at the beginning of each script before any output is sent to the browser? Ken More info perhaps. Changes I make using the page's form are persevered. Any changes made with php are not saved. Checking the session file confirms this. I'm missing something obvious here. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variable problem
More info (including some code) would be needed to get to the bottom of this, I'd say. Hard to diagnose what's happening otherwise. Regards Peter -- hype WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variable Problem
tedd Please accept my apologies for not thanking you sooner, I am going over you code and learning great stuff. Again, thank you. And thank you to Adam as well. gary tedd tedd.sperl...@gmail.com wrote in message news:p06240804c7cbe9aa1...@[192.168.1.102]... At 10:14 AM -0400 3/21/10, Gary wrote: Thanks again for all the help, however the plot thickens. Gary : It doesn't have to thicken. Here's an example of using $_SESSION that works and you can have as many fields as you want: http://www.webbytedd.com/aa/step-form-sessions/index.php All the code is there. Plus, it will give you a way to go from page to page without leaving the gathering page. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com __ Information from ESET Smart Security, version of virus signature database 4962 (20100321) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4965 (20100322) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variable Problem
At 2:22 PM -0400 3/20/10, Gary wrote: I have this perplexing issue of session varibles getting dropped. It is a 4 page form, the last page being a review page incase the submitter wants to change any of the information.If you go through the form, all of the information carries forward, and from the review page if you go back to edit, it is there, however is you go back to page 2, then to page 1, page one info is gone.It gets worse in that page 2 sessions drop (more likely over written) if you go from page 3 to 2. Each page is started with ?php if(!isset($_SESSION)) { session_start(); } Session varible: $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); Calling the session varible to the input field for review ?php if (isset($_SESSION['lend_fname'])) {echo 'value='.htmlentities($_SESSION['lend_fname']).'';}? The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php Im confused as to why they keep getting dropped and how to stop it. Hopefully I have given enough information. Thank you Gary Gary: I think I know what the problem is. When you revisit previous pages, you write over the previous data from an empty $_POST. Here's a way to stop that. ?php session_start(); if (isset($_POST ['lend_fname']) { $_SESSION['lend_fname'] = $_POST['lend_fname']; } As far as using strip_slashes() and htmlentities() I wait until I am going to use the variables in some manner and then clean/scrub them all at one time. That makes the process simpler for me -- plus I can then keep all my security checks in one location. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variable Problem
Thanks again for all the help, however the plot thickens. I have put: ?php if(!isset($_SESSION)) { session_start(); } if (isset($_POST['lend_fname'])){ $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); } if (isset($_POST['lend_lname'])){ $_SESSION['lend_lname']=stripslashes($_POST['lend_lname']); } if (isset($_POST['lend_street'])){ $_SESSION['lend_street']=stripslashes($_POST['lend_street']); } if (isset($_POST['lend_city'])){ $_SESSION['lend_city']=stripslashes($_POST['lend_city']); } if (isset($_POST['lend_state'])){ $_SESSION['lend_state']=stripslashes($_POST['lend_state']); } if (isset($_POST['lend_lname'])){ $_SESSION['lend_zip']=stripslashes($_POST['lend_zip']); } if (isset($_POST['lend_email'])){ $_SESSION['lend_email']=stripslashes($_POST['lend_email']); } if (isset($_POST['lend_phone'])){ $_SESSION['lend_phone']=stripslashes($_POST['lend_phone']); } ? On the first page, Now what happens is it only sticks to the first two (lend_fname and lend_lname), the others still get lost. Any idea how or why the exact code works differently? Thanks Again. gary tedd tedd.sperl...@gmail.com wrote in message news:p06240800c7cbc0927...@[192.168.1.102]... At 2:22 PM -0400 3/20/10, Gary wrote: I have this perplexing issue of session varibles getting dropped. It is a 4 page form, the last page being a review page incase the submitter wants to change any of the information.If you go through the form, all of the information carries forward, and from the review page if you go back to edit, it is there, however is you go back to page 2, then to page 1, page one info is gone.It gets worse in that page 2 sessions drop (more likely over written) if you go from page 3 to 2. Each page is started with ?php if(!isset($_SESSION)) { session_start(); } Session varible: $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); Calling the session varible to the input field for review ?php if (isset($_SESSION['lend_fname'])) {echo 'value='.htmlentities($_SESSION['lend_fname']).'';}? The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php Im confused as to why they keep getting dropped and how to stop it. Hopefully I have given enough information. Thank you Gary Gary: I think I know what the problem is. When you revisit previous pages, you write over the previous data from an empty $_POST. Here's a way to stop that. ?php session_start(); if (isset($_POST ['lend_fname']) { $_SESSION['lend_fname'] = $_POST['lend_fname']; } As far as using strip_slashes() and htmlentities() I wait until I am going to use the variables in some manner and then clean/scrub them all at one time. That makes the process simpler for me -- plus I can then keep all my security checks in one location. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com __ Information from ESET Smart Security, version of virus signature database 4962 (20100321) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4962 (20100321) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variable Problem
At 10:14 AM -0400 3/21/10, Gary wrote: Thanks again for all the help, however the plot thickens. Gary : It doesn't have to thicken. Here's an example of using $_SESSION that works and you can have as many fields as you want: http://www.webbytedd.com/aa/step-form-sessions/index.php All the code is there. Plus, it will give you a way to go from page to page without leaving the gathering page. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Variable Problem
I have this perplexing issue of session varibles getting dropped. It is a 4 page form, the last page being a review page incase the submitter wants to change any of the information.If you go through the form, all of the information carries forward, and from the review page if you go back to edit, it is there, however is you go back to page 2, then to page 1, page one info is gone.It gets worse in that page 2 sessions drop (more likely over written) if you go from page 3 to 2. Each page is started with ?php if(!isset($_SESSION)) { session_start(); } Session varible: $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); Calling the session varible to the input field for review ?php if (isset($_SESSION['lend_fname'])) {echo 'value='.htmlentities($_SESSION['lend_fname']).'';}? The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php Im confused as to why they keep getting dropped and how to stop it. Hopefully I have given enough information. Thank you Gary __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variable Problem
On Sat, Mar 20, 2010 at 2:22 PM, Gary gwp...@ptd.net wrote: I have this perplexing issue of session varibles getting dropped. It is a 4 page form, the last page being a review page incase the submitter wants to change any of the information.If you go through the form, all of the information carries forward, and from the review page if you go back to edit, it is there, however is you go back to page 2, then to page 1, page one info is gone.It gets worse in that page 2 sessions drop (more likely over written) if you go from page 3 to 2. Each page is started with ?php if(!isset($_SESSION)) { session_start(); } Session varible: $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); Calling the session varible to the input field for review ?php if (isset($_SESSION['lend_fname'])) {echo 'value='.htmlentities($_SESSION['lend_fname']).'';}? The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php Im confused as to why they keep getting dropped and how to stop it. Hopefully I have given enough information. Thank you Gary __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Are you checking to see if the post variable is set in the code that handles saving the form values to session variables? I can't tell if you're doing this from the code you provided. If not, it's possible that when you are returning to one of the earlier pages, you're attempting to again save the form values even though the corresponding $_POST vars are empty. This would cause visiting page 2 to essentially delete the data previously posted from page 1. Using your example: // Only save if post variable present, which means if (isset($_POST['lend_fname'])) { $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); } Also, some users will likely click the back button during the process, which brings up a funky message. You might try building one page that is dedicated to saving all of the session variables, which then redirects to the corresponding next page in the process. Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] Session Variable Problem
Adam Thank you for your reply. Are you checking to see if the post variable is set in the code that handles saving the form values to session variables? No, I not done anything about the post variable, frankly I thought the session variable would cover it. I tried your code if (isset($_POST['lend_fname'])){ $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); } And it seems to work fine, the data seems to stay. Is there an easier method (perhaps putting the post or session variables into an array? Again thank you for your reply and your solution. Gary Adam Richardson simples...@gmail.com wrote in message news:e4d8ea9d1003201529p1ab72baei147549423f5e3...@mail.gmail.com... On Sat, Mar 20, 2010 at 2:22 PM, Gary gwp...@ptd.net wrote: I have this perplexing issue of session varibles getting dropped. It is a 4 page form, the last page being a review page incase the submitter wants to change any of the information.If you go through the form, all of the information carries forward, and from the review page if you go back to edit, it is there, however is you go back to page 2, then to page 1, page one info is gone.It gets worse in that page 2 sessions drop (more likely over written) if you go from page 3 to 2. Each page is started with ?php if(!isset($_SESSION)) { session_start(); } Session varible: $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); Calling the session varible to the input field for review ?php if (isset($_SESSION['lend_fname'])) {echo 'value='.htmlentities($_SESSION['lend_fname']).'';}? The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php Im confused as to why they keep getting dropped and how to stop it. Hopefully I have given enough information. Thank you Gary __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Are you checking to see if the post variable is set in the code that handles saving the form values to session variables? I can't tell if you're doing this from the code you provided. If not, it's possible that when you are returning to one of the earlier pages, you're attempting to again save the form values even though the corresponding $_POST vars are empty. This would cause visiting page 2 to essentially delete the data previously posted from page 1. Using your example: // Only save if post variable present, which means if (isset($_POST['lend_fname'])) { $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); } Also, some users will likely click the back button during the process, which brings up a funky message. You might try building one page that is dedicated to saving all of the session variables, which then redirects to the corresponding next page in the process. Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variable Problem
On Sat, Mar 20, 2010 at 6:56 PM, Gary gwp...@ptd.net wrote: Adam Thank you for your reply. Are you checking to see if the post variable is set in the code that handles saving the form values to session variables? No, I not done anything about the post variable, frankly I thought the session variable would cover it. I tried your code if (isset($_POST['lend_fname'])){ $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); } And it seems to work fine, the data seems to stay. Is there an easier method (perhaps putting the post or session variables into an array? Again thank you for your reply and your solution. Gary Adam Richardson simples...@gmail.com wrote in message news:e4d8ea9d1003201529p1ab72baei147549423f5e3...@mail.gmail.com... On Sat, Mar 20, 2010 at 2:22 PM, Gary gwp...@ptd.net wrote: I have this perplexing issue of session varibles getting dropped. It is a 4 page form, the last page being a review page incase the submitter wants to change any of the information.If you go through the form, all of the information carries forward, and from the review page if you go back to edit, it is there, however is you go back to page 2, then to page 1, page one info is gone.It gets worse in that page 2 sessions drop (more likely over written) if you go from page 3 to 2. Each page is started with ?php if(!isset($_SESSION)) { session_start(); } Session varible: $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); Calling the session varible to the input field for review ?php if (isset($_SESSION['lend_fname'])) {echo 'value='.htmlentities($_SESSION['lend_fname']).'';}? The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php Im confused as to why they keep getting dropped and how to stop it. Hopefully I have given enough information. Thank you Gary __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Are you checking to see if the post variable is set in the code that handles saving the form values to session variables? I can't tell if you're doing this from the code you provided. If not, it's possible that when you are returning to one of the earlier pages, you're attempting to again save the form values even though the corresponding $_POST vars are empty. This would cause visiting page 2 to essentially delete the data previously posted from page 1. Using your example: // Only save if post variable present, which means if (isset($_POST['lend_fname'])) { $_SESSION['lend_fname']=stripslashes($_POST['lend_fname']); } Also, some users will likely click the back button during the process, which brings up a funky message. You might try building one page that is dedicated to saving all of the session variables, which then redirects to the corresponding next page in the process. Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4961 (20100320) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The session variables store what you tell them to store. The way your pages were set up, it sounds like you always called the code that set the session variable, even if the session variable was already set and even if there were no POST variables sent. People often do use sessions to preserve the state of a form's fields if the form has multiple pages, just as you are doing. In this type of situation someone can be visiting a page to 1) submit new data (POST data is present such as when somebody clicks on the submit button in the previous page), or 2) review the data they've already entered (no POST data present, such as when somebody uses the navigation on your page.) You have to check to see which of the two possible types of page requests is occurring. Using the code you have, you can probably just wrap the code that you have that sets the session variables in an if block that checks for one of the post variables you're expecting. I'd recommend reading a tutorial or two on how PHP sessions work, such as the following: http://php.about.com/od/advancedphp/ss/php_sessions.htm Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
[PHP] Session variable problem
Hello, I'd like to use session variable. I do that (see below) but I receive an error. Other question, how can I do to know if a session variable is already defined ? ?php session_start()? ?php$_SESSION[LG] = 'EN';? !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head titletitle /head body /body /html But I receive this error : Parse error: parse error, unexpected T_VARIABLE in d:\inetpub\wwwroot\test\index.php on line 2 thanks, Christian, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variable problem
Add a missing space. ok thanks :) How use this variable in a query (mysql_query) ? Is it possible if a session variable is already defined ? Bye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session variable problem
i am starting and registering session variable succesfully that i can see the file on the server , but when it comes to use or display i can not , the variable has no value ... the "session.save_handler = files" is in php.ini , i tried to change it to user but that occured a fatal error etc.. So shortly what is the thing that i am missing thanks alot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] session variable problem
The reason for the fatal error is that you can only store the sessions in three (or four) ways, files, in a database or in the memory. What variable has no value? Have you started the session before you try to access the values? session_start(); echo $your_value; (Or preferably) echo $HTTP_SESSION_VARS["your_value"]; Here is a little code for you to test if you can read the session variables: session_start(); while(list($key, $val) = each($HTTP_SESSION_VARS)) echo "Variables name: $key - The value: $val"; } "SERKAN BALKANLI (EBÝ Bþk.-Analist Prog.)" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... i am starting and registering session variable succesfully that i can see the file on the server , but when it comes to use or display i can not , the variable has no value ... the "session.save_handler = files" is in php.ini , i tried to change it to user but that occured a fatal error etc.. So shortly what is the thing that i am missing thanks alot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] session variable problem
Merhabalar, firstly do you use windows or linux? id you use windows you shoul give the session_save_path to the script. ( session_save_path("c:\\user\\tmp"); ) if you use linux and no changes in your .ini files, your sessions store in /tmp directory... ?php session_start(); $id = 123; session_register('id'); ? html head title/title /head body ?php echo $id; ? /body /html Kolay Gele... Mesut... SERKAN BALKANLI (EB Bk.-Analist Prog.) wrote: i am starting and registering session variable succesfully that i can see the file on the server , but when it comes to use or display i can not , the variable has no value ... the "session.save_handler = files" is in php.ini , i tried to change it to user but that occured a fatal error etc.. So shortly what is the thing that i am missing thanks alot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]