Re: [PHP] PHP session variables
On Aug 15, 2012, at 4:13 PM, Robert Cummings wrote: > > I only pointed it out because I used to do exactly the same thing :) > > Cheers, > Rob. Thanks, I was starting to feel pretty dumb. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 15, 2012, at 4:42 PM, Andrew Ballard wrote: > On Wed, Aug 15, 2012 at 3:24 PM, Tedd Sperling wrote: >> The php manual ( http://us3.php.net/manual/en/function.session-start.php ) >> >> First Note states that session_start() must be called *before* anything sent >> to the Browser. >> >> So, to rewrite your code -- >> >> for($i=1; $i < 1000; $i++) >> { >> if (!defined('SID')) >> { >> session_start(); >> echo __LINE__, '::session_start()'; >> } >> } >> >> -- should work better, right? >> >> Cheers, >> >> tedd > > > -snip- > However, due to the nature of your test page you are still > sending output from the first loop before you call session_start() in > the second loop. Duh! Too many brain surgeons working on this brain! In the real world neither of us would have made those mistakes. It is only when we try to make things simple do we over complicate. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Wed, Aug 15, 2012 at 3:24 PM, Tedd Sperling wrote: > Your points are well taken -- thanks. I've seen a lot of people code that way, so it's easy to miss. In your original code, that first statement was calling session_start() 1,000 times. This is because the first time through, SID is undefined so defined(SID) was equivalent to defined('SID') and both would have returned false. After the first session_start(), though, SID WAS defined, but would have had some pseudo-random session identifier as its value. As a result, the last 999 times through your loop, you were actually scanning the defined constants to see if there was one named something like '7cjubadsh5lkq80opemht2ea03'. Obviously, it would never exist. > However, my only concern is given this: > >> for($i=1; $i < 1000; $i++) >>{ >>if (!defined('SID')) >> { >> echo __LINE__, '::session_start()'; >> session_start(); >> } >>} > > The php manual ( http://us3.php.net/manual/en/function.session-start.php ) > > First Note states that session_start() must be called *before* anything sent > to the Browser. > > So, to rewrite your code -- > > for($i=1; $i < 1000; $i++) >{ >if (!defined('SID')) > { > session_start(); > echo __LINE__, '::session_start()'; > } >} > > -- should work better, right? > > Cheers, > > tedd Yes, that is more correct. I think we have output buffering enabled on most of our servers (a lot of our legacy stuff really depends on it) so I didn't notice any errors, but you are correct. You really don't need the echo lines that I added in your test at all though. I just threw it in there to be able to see when the function was being called. However, due to the nature of your test page you are still sending output from the first loop before you call session_start() in the second loop. To be absolutely correct, you'd have to remove those echo statements I added for debugging, store all of your timings in separate variables and then output them at the end of the script. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On 12-08-15 03:19 PM, Tedd Sperling wrote: Rob: Again thanks. Sorry, I totally missed your point. In my "defense" I commonly use the value returned from microtime() as a string and not as a float. The code that followed my "microtime( false );" demo broke the string and recombined it into a float. So, when you said: Please see the current signature for microtime(): mixed microtime ([ bool $get_as_float = false ] ) I looked at that and said to myself, "Oh, I need to define it as 'false' " because I was using it as a sting. I completely overlooked your point that microtime() could return a float and thus no need to work with it as a string -- duh! The demo is fixed (I think): http://www.webbytedd.com/b/timed1/ Thanks, tedd I only pointed it out because I used to do exactly the same thing :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
Andrew: Your points are well taken -- thanks. However, my only concern is given this: > for($i=1; $i < 1000; $i++) >{ >if (!defined('SID')) > { > echo __LINE__, '::session_start()'; > session_start(); > } >} The php manual ( http://us3.php.net/manual/en/function.session-start.php ) First Note states that session_start() must be called *before* anything sent to the Browser. So, to rewrite your code -- for($i=1; $i < 1000; $i++) { if (!defined('SID')) { session_start(); echo __LINE__, '::session_start()'; } } -- should work better, right? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 14, 2012, at 11:01 AM, Robert Cummings wrote: > > I'm not sure if you're making a joke, but your changes have no effect. You've > merely explicitly stated the optional parameter's default value. What I had > meant was to change the following: > > > $starttime = microtime(); > $startarray = explode(" ", $starttime); > $starttime = $startarray[1] + $startarray[0]; > > ?> > > To the following :) > > > $starttime = microtime( true ); > > ?> > > Cheers, > Rob. Rob: Again thanks. Sorry, I totally missed your point. In my "defense" I commonly use the value returned from microtime() as a string and not as a float. The code that followed my "microtime( false );" demo broke the string and recombined it into a float. So, when you said: Please see the current signature for microtime(): mixed microtime ([ bool $get_as_float = false ] ) I looked at that and said to myself, "Oh, I need to define it as 'false' " because I was using it as a sting. I completely overlooked your point that microtime() could return a float and thus no need to work with it as a string -- duh! The demo is fixed (I think): http://www.webbytedd.com/b/timed1/ Thanks, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Fri, Aug 10, 2012 at 11:56 AM, Tedd Sperling wrote: > On Aug 10, 2012, at 11:45 AM, Tedd Sperling wrote: > >> On Aug 9, 2012, at 5:16 PM, Jim Lucas wrote: >>> You are relying on PHP's loose typing. This is a poor check. >>> >>> session_id() returns a string, not boolean. >>> >>> You should do this instead. >>> >>> if ( session_id() === '' ) >>> >>> >>> >>> -- >>> Jim Lucas >> >> Thanks Jim -- you're right. >> >> What about? >> >> if (!defined(SID)) >> { >> session_start(); >> } > > Before you answer, the "(!defined(SID))" is over 50 times slower than "( > session_id() === '' )" > > Your way is better. > > Cheers, > > tedd tedd, I think this is because you passed SID to defined() as a constant rather than a string, so the if test always returns true. When I changed this to if (!defined('SID')) { session _start(); } it worked as expected, and I got much more similar results. I also added a call to session_destroy() between the two tests so that each loop initialized the session once. (In your test, the second loop never initializes the session since it was already started by the first loop.) This is your code with my modifications: '; session_start(); } } session_destroy(); $endtime = microtime(true); $totaltime = $endtime - $starttime; $totaltime = round($totaltime,5); echo "First in $totaltime seconds."; $starttime = microtime(true); // whatever you want timed, you do here. for($i=1; $i < 1000; $i++) { if (session_id() ==='') { echo __LINE__, '::session_start()'; session_start(); } } $endtime = microtime(true); $totaltime = $endtime - $starttime; $totaltime = round($totaltime,5); echo "Second in $totaltime seconds."; session_destroy(); ?> Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 14, 2012 1:36 AM, "tamouse mailing lists" wrote: > > > On Aug 13, 2012 8:01 AM, "Robert Cummings" wrote: > > > > On 12-08-10 04:42 PM, Tedd Sperling wrote: > >> > >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: > >> > >>> Hi. My question will maybe out of topic, I'm sorry. > >>> How can you know that one way will be much slower than other one? I mean, how can I learn which function is faster before I test it? > >> > >> > >> Ege: > >> > >> No your question is on topic. > >> > >> This question should be asked on the list, so I'll present Q:A instead of answering privately > >> > >> http://www.webbytedd.com/b/timed1/ > >> > >> The code is there -- if you have questions, please post them to the list. > > > > > > Ted, > > > > Please see the current signature for microtime(): > > > > mixed microtime ([ bool $get_as_float = false ] ) > > > > The optional paramter was added in PHP 5.0.0. I think it's safe to update your habits :) > > > > Cheers, > > Rob. > > -- > > E-Mail Disclaimer: Information contained in this message and any > > attached documents is considered confidential and legally protected. > > This message is intended solely for the addressee(s). Disclosure, > > copying, and distribution are prohibited unless authorized. > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > What are the timing values if you do something besides session start with no close? Just to clarify, since at least 4.3.x subsequent calls session_start raise an E_NOTICE and are ignored, so you're first call is generating almost all the time.
Re: [PHP] PHP session variables
On 12-08-14 10:41 AM, Tedd Sperling wrote: On Aug 13, 2012, at 10:59 AM, Robert Cummings wrote: On 12-08-10 04:42 PM, Tedd Sperling wrote: On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: Hi. My question will maybe out of topic, I'm sorry. How can you know that one way will be much slower than other one? I mean, how can I learn which function is faster before I test it? Ege: No your question is on topic. This question should be asked on the list, so I'll present Q:A instead of answering privately http://www.webbytedd.com/b/timed1/ The code is there -- if you have questions, please post them to the list. Ted, Please see the current signature for microtime(): mixed microtime ([ bool $get_as_float = false ] ) The optional paramter was added in PHP 5.0.0. I think it's safe to update your habits :) Cheers, Rob. Rob: Fixed. Thanks -- my habits are always in a state of being updated -- just ask my wife. I'm not sure if you're making a joke, but your changes have no effect. You've merely explicitly stated the optional parameter's default value. What I had meant was to change the following: To the following :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 13, 2012, at 10:59 AM, Robert Cummings wrote: > On 12-08-10 04:42 PM, Tedd Sperling wrote: >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: >> >>> Hi. My question will maybe out of topic, I'm sorry. >>> How can you know that one way will be much slower than other one? I mean, >>> how can I learn which function is faster before I test it? >> >> Ege: >> >> No your question is on topic. >> >> This question should be asked on the list, so I'll present Q:A instead of >> answering privately >> >> http://www.webbytedd.com/b/timed1/ >> >> The code is there -- if you have questions, please post them to the list. > > Ted, > > Please see the current signature for microtime(): > >mixed microtime ([ bool $get_as_float = false ] ) > > The optional paramter was added in PHP 5.0.0. I think it's safe to update > your habits :) > > Cheers, > Rob. Rob: Fixed. Thanks -- my habits are always in a state of being updated -- just ask my wife. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 13, 2012 8:01 AM, "Robert Cummings" wrote: > > On 12-08-10 04:42 PM, Tedd Sperling wrote: >> >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: >> >>> Hi. My question will maybe out of topic, I'm sorry. >>> How can you know that one way will be much slower than other one? I mean, how can I learn which function is faster before I test it? >> >> >> Ege: >> >> No your question is on topic. >> >> This question should be asked on the list, so I'll present Q:A instead of answering privately >> >> http://www.webbytedd.com/b/timed1/ >> >> The code is there -- if you have questions, please post them to the list. > > > Ted, > > Please see the current signature for microtime(): > > mixed microtime ([ bool $get_as_float = false ] ) > > The optional paramter was added in PHP 5.0.0. I think it's safe to update your habits :) > > Cheers, > Rob. > -- > E-Mail Disclaimer: Information contained in this message and any > attached documents is considered confidential and legally protected. > This message is intended solely for the addressee(s). Disclosure, > copying, and distribution are prohibited unless authorized. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > What are the timing values if you do something besides session start with no close?
Re: [PHP] PHP session variables
On 12-08-10 04:42 PM, Tedd Sperling wrote: On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: Hi. My question will maybe out of topic, I'm sorry. How can you know that one way will be much slower than other one? I mean, how can I learn which function is faster before I test it? Ege: No your question is on topic. This question should be asked on the list, so I'll present Q:A instead of answering privately http://www.webbytedd.com/b/timed1/ The code is there -- if you have questions, please post them to the list. Ted, Please see the current signature for microtime(): mixed microtime ([ bool $get_as_float = false ] ) The optional paramter was added in PHP 5.0.0. I think it's safe to update your habits :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: > Hi. My question will maybe out of topic, I'm sorry. > How can you know that one way will be much slower than other one? I mean, how > can I learn which function is faster before I test it? Ege: No your question is on topic. This question should be asked on the list, so I'll present Q:A instead of answering privately http://www.webbytedd.com/b/timed1/ The code is there -- if you have questions, please post them to the list. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
Am 09.08.12 23:16, schrieb Jim Lucas: > On 08/09/2012 01:45 PM, Tedd Sperling wrote: >> On Aug 8, 2012, at 5:41 PM, Jim Giner >> wrote: >> >>> On 8/8/2012 11:24 AM, Ansry User 01 wrote: I am setting the _SESSION variables in one of my file, but whenever I leave the php page session variables are not accessible. Not sure what I need to do additionally other then defining _SESSION[]. Any pointer. >>> You must make it a habit to start each script with >>> >>> session_start(); You should definitely not make that a habbit! Why create/open a session and send a cookie everytime script call even if you won't need it? Why access a hard disk to create/open a session file even if there is no use for it? Only call session_start() if you need it and call session_write_close() as early as possible to avoid write locks on the users session file. And up from PHP 5.4 you can use http://de2.php.net/manual/de/function.session-status.php to check a session status. -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz signature.asc Description: OpenPGP digital signature
Re: [PHP] PHP session variables
On Aug 10, 2012, at 11:45 AM, Tedd Sperling wrote: > On Aug 9, 2012, at 5:16 PM, Jim Lucas wrote: >> You are relying on PHP's loose typing. This is a poor check. >> >> session_id() returns a string, not boolean. >> >> You should do this instead. >> >> if ( session_id() === '' ) >> >> >> >> -- >> Jim Lucas > > Thanks Jim -- you're right. > > What about? > > if (!defined(SID)) > { > session_start(); > } Before you answer, the "(!defined(SID))" is over 50 times slower than "( session_id() === '' )" Your way is better. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 9, 2012, at 5:16 PM, Jim Lucas wrote: > You are relying on PHP's loose typing. This is a poor check. > > session_id() returns a string, not boolean. > > You should do this instead. > > if ( session_id() === '' ) > > > > -- > Jim Lucas Thanks Jim -- you're right. What about? if (!defined(SID)) { session_start(); } Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On 08/09/2012 01:45 PM, Tedd Sperling wrote: On Aug 8, 2012, at 5:41 PM, Jim Giner wrote: On 8/8/2012 11:24 AM, Ansry User 01 wrote: I am setting the _SESSION variables in one of my file, but whenever I leave the php page session variables are not accessible. Not sure what I need to do additionally other then defining _SESSION[]. Any pointer. You must make it a habit to start each script with session_start(); I like this way: if (!session_id()) { session_start(); } Cheers, tedd _ t...@sperling.com http://sperling.com You are relying on PHP's loose typing. This is a poor check. session_id() returns a string, not boolean. You should do this instead. if ( session_id() === '' ) -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 8, 2012, at 5:41 PM, Jim Giner wrote: > On 8/8/2012 11:24 AM, Ansry User 01 wrote: >> I am setting the _SESSION variables in one of my file, but whenever I leave >> the php page session variables are not accessible. Not sure what I need to >> do additionally other then defining _SESSION[]. >> Any pointer. >> > You must make it a habit to start each script with > > session_start(); > I like this way: if (!session_id()) { session_start(); } Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP session variables
On 8/8/2012 11:24 AM, Ansry User 01 wrote: I am setting the _SESSION variables in one of my file, but whenever I leave the php page session variables are not accessible. Not sure what I need to do additionally other then defining _SESSION[]. Any pointer. You must make it a habit to start each script with session_start(); so that any thing you did in the last script is returned for use in the new script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP session variables
-Original Message- From: David Harkness [mailto:davi...@highgearmedia.com] Sent: Wednesday, August 08, 2012 11:53 AM To: Ansry User 01 Cc: php-general@lists.php.net Subject: Re: [PHP] PHP session variables On Wed, Aug 8, 2012 at 8:24 AM, Ansry User 01 wrote: > I am setting the _SESSION variables in one of my file, but whenever I > leave the php page session variables are not accessible. As always, post some code demonstrating what you're doing. Help us help you! :) David You have to set session_start also on the page where you are trying to retrieve the session variables. Jen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Wed, Aug 8, 2012 at 8:24 AM, Ansry User 01 wrote: > I am setting the _SESSION variables in one of my file, but whenever I > leave the php page session variables are not accessible. As always, post some code demonstrating what you're doing. Help us help you! :) David
Re: [PHP] PHP session variables
On Wed, Aug 8, 2012 at 11:24 AM, Ansry User 01 wrote: > I am setting the _SESSION variables in one of my file, but whenever I leave > the php page session variables are not accessible. Not sure what I need to do > additionally other then defining _SESSION[]. > Any pointer. If you're not telling PHP (in php.ini) to auto-start the session, then you'll need session_start() before accessing $_SESSION. If you're certain the session is being properly instantiated in the code, make sure that the user as which the web server (Apache, et al) is running has permission and available disk space to access the session storage media (file system such as /tmp, database table, et cetera). -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Variables - Error
Dear List - Thanks for your help. Here is another one. I cannot get my session variables to work. The program will print out a chess board and show the positions of the pieces after the move Here are code snippets: The program is chess2.php $results = array(array("Br", "Bn", "Bb", "Bq", "Bk", "Bb", "Bn", "Br"),array("Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp"), array("", "", "", "", "", "", "", ""),array("", "", "", "", "", "", "", ""),array("", "", "", "", "", "", "", ""), array("", "", "", "", "", "", "", ""),array("Wp", "Wp", "Wp", "Wp", "Wp", "Wp", "Wp", "Wp"), array("Wr", "Wn", "Wb", "Wq", "Wk", "Wb", "Wn", "Wr")); $_SESSION['results'] = $results; print_r($_SESSION); } else { $results = $_SESSION['results']; echo "starting values"; print_r($results); } ?> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> . . . . . Move Fromname="move_from"> Move To name="move_to"> "; echo "from_before = "; print_r($from_before); echo""; $to = '$'. $_POST[move_to]; echo "to = $to"; //$to = $from; $from = '' ; echo""; echo "from after = $from"; echo""; echo "to after = $to"; $board = array //Correlation of input array [chessboard] with internal array [results] ( a8 => $results[0][0], b8 => $results[0][1], c8 => $results[0][2], d8 => $results[0][3], e8 => $results[0][4], f8 => $results[0][5], . . . . f1 => $results[7][5], g1 => $results[7][6], h1 => $results[7][7], ); for($i = 0; $i <8; $i++) // I get the correct results here { for ($j = 0; $j < 8; $j++) printf("%s ", $results[$i][$j]); printf(""); } $_SESSION['results'] = $results; Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables in tmp
Ok, that usually happens. Gerardo www.webseficientes.com.ar On Tue, Jun 8, 2010 at 1:48 PM, Stephen Sunderlin < stephen.sunder...@verizon.net> wrote: > Thanks Gerardo. > > I send a large dump.sql file to my /tmp dir and filled up the remaining > space so PHP was not able to write any more session variable. Took me a > little while to figure that one out. > > Thanks for your response. > > > > > > On Tue, 08 Jun 2010 12:00:23 -0400, Gerardo Benitez > wrote: > > Hi Stephen, >> >> you can try setting the session path using session_save_path >> http://www.php.net/manual/en/function.session-save-path.php. >> >> Gerardo >> www.webseficientes.com.ar >> >> >> >> On Sat, Jun 5, 2010 at 2:18 AM, Stephen Sunderlin < >> stephen.sunder...@verizon.net> wrote: >> >> trying out a CentOS release 5.2 (Final) V4_1_0 on AWS. Was working fine >>> and now it seems that php has stopped writing any session variable to >>> /tmp. >>> I was cleaning up the user table in mysql and limiting permissions. >>> Not >>> sure that this would have anything to do with it. Restarted >>> apache/mysql. >>> tmp is set to drwxrwxrwt 4 root root 4096 Jun 5 00:46 tmp >>> PHP 5.2.4 >>> MySQL 5.0.45 >>> any thought on where else to look. >>> >>> Thanks. >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >>> >> >> > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ > -- Gerardo Benitez
Re: [PHP] session variables in tmp
Thanks Gerardo. I send a large dump.sql file to my /tmp dir and filled up the remaining space so PHP was not able to write any more session variable. Took me a little while to figure that one out. Thanks for your response. On Tue, 08 Jun 2010 12:00:23 -0400, Gerardo Benitez wrote: Hi Stephen, you can try setting the session path using session_save_path http://www.php.net/manual/en/function.session-save-path.php. Gerardo www.webseficientes.com.ar On Sat, Jun 5, 2010 at 2:18 AM, Stephen Sunderlin < stephen.sunder...@verizon.net> wrote: trying out a CentOS release 5.2 (Final) V4_1_0 on AWS. Was working fine and now it seems that php has stopped writing any session variable to /tmp. I was cleaning up the user table in mysql and limiting permissions. Not sure that this would have anything to do with it. Restarted apache/mysql. tmp is set to drwxrwxrwt 4 root root 4096 Jun 5 00:46 tmp PHP 5.2.4 MySQL 5.0.45 any thought on where else to look. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables in tmp
Hi Stephen, you can try setting the session path using session_save_path http://www.php.net/manual/en/function.session-save-path.php. Gerardo www.webseficientes.com.ar On Sat, Jun 5, 2010 at 2:18 AM, Stephen Sunderlin < stephen.sunder...@verizon.net> wrote: > trying out a CentOS release 5.2 (Final) V4_1_0 on AWS. Was working fine > and now it seems that php has stopped writing any session variable to /tmp. > I was cleaning up the user table in mysql and limiting permissions. Not > sure that this would have anything to do with it. Restarted apache/mysql. > tmp is set to drwxrwxrwt 4 root root 4096 Jun 5 00:46 tmp > PHP 5.2.4 > MySQL 5.0.45 > any thought on where else to look. > > Thanks. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Gerardo Benitez
[PHP] session variables in tmp
trying out a CentOS release 5.2 (Final) V4_1_0 on AWS. Was working fine and now it seems that php has stopped writing any session variable to /tmp. I was cleaning up the user table in mysql and limiting permissions. Not sure that this would have anything to do with it. Restarted apache/mysql. tmp is set to drwxrwxrwt 4 root root 4096 Jun 5 00:46 tmp PHP 5.2.4 MySQL 5.0.45 any thought on where else to look. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables and SVG documents
On Wed, Feb 3, 2010 at 8:20 AM, Ashley Sheridan wrote: > On Wed, 2010-02-03 at 10:49 +0100, Aurelie REYMUND wrote: > > > Hello, > > > > unfortunately, it does not suite my needs. The image must be clickable. > The > > application I'm developping reads data from a database and display the > > information graphically. The user must be able to click on some elements > of > > the picture, and I have to store the information the user clicked on > > (session vars). I cannot tell the user not to use IE, so I have to find > > another solution... > > > > Regards, > > Aurelie > > > > 2010/2/1 Ray Solomon > > > > > From: "Aurelie REYMUND" > > > Sent: Monday, February 01, 2010 3:37 AM > > > To: > > > Subject: [PHP] session variables and SVG documents > > > > > > > > > Hello, > > >> > > >> I have the following problem with the Adobe SVG viewer: > > >> I try to generate a SVG document using PHP. the following code is > working > > >> well under Firefox, as well as IE with ASV: > > >> > > >> > >> > > >> header("Content-type: image/svg+xml"); > > >> > > >> $graph_title = 'title'; > > >> > > >> > > >> print(''); > > >> $svgwidth=500; > > >> $svgheight=400; > > >> ?> > > >> > > >> > >> http://www.w3.org/TR/SVG/DTD/svg10.dtd";> > > >> > >> xmlns="http://www.w3.org/2000/svg";> > > >> This is a php-random rectangle test > > >> > >> srand((double) microtime() * 100); //initalizing random generator > > >> for ($i = 0; $i < 20; $i+=1) { > > >> $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for > rand > > >> function > > >> $y = floor(rand(0,$svgheight-1)); > > >> $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside > of > > >> viewbox > > >> $height = floor(rand(0,$svgheight-$y)); > > >> $red = floor(rand(0,255)); > > >> $blue = floor(rand(0,255)); > > >> $green = floor(rand(0,255)); > > >> $color = "rgb(".$red.",".$green.",".$ > > >> blue.")"; > > >> print "\t > >> style=\"fill:$color;\"/>\n"; > > >> } > > >> ?> > > >>> >> text-anchor="middle">The servers Date and Time is: > >> (strftime("%Y-%m-%d, %H:%M:%S")); ?> > > >>> >> text-anchor="middle">You are running: > > >>> >> text-anchor="middle"> > > >> > > >> > > >> If now I want to include the session_start() at the beginning of the > code, > > >> in IE I got a pop-up dialog called "download file" > > >> > > >> What am I doing wrong ? > > >> > > >> Regards, > > >> Aurelie > > >> > > >> > > > > > > It appears IE does not support svg yet and you need a plugin for it. > > > > > > However, you could also design your code differently by using > Imagemagick > > > to convert the svg to png. > > > If that suits your needs, then use the modified code below: > > > > > > > > > > > > > > header("Content-type: image/png"); > > > > > > $graph_title = 'title'; > > > > > > $svgwidth=500; > > > $svgheight=400; > > > > > > $svg = ' > > > http://www.w3.org/2000/svg";> > > > This is a php-random rectangle test'; > > > > > > > > > for ($i = 0; $i < 20; $i++) { > > > > > >$x = floor(rand(0,$svgwidth-1)); > > >$y = floor(rand(0,$svgheight-1)); > > >$width = floor(rand(0,$svgwidth-$x)); > > >$height = floor(rand(0,$svgheight-$y)); > > >$red = floor(rand(0,255)); > > >$blue = floor(rand(0,255)); > > >$green = floor(rand(0,255)); > > >$color = "rgb(".$red.",".$green.",".$blue.")"; > > >$svg .= "\t > > height=\"$height\" style=\"fill:$color;\"/>\n"; > > > } > > > > > > $svg .= ' > > text-anchor="middle">The servers Date and Time is: '.date("Y-m-d, > > > H:m:s").' > > >> > text-anchor="middle">You are running: > > >> > text-anchor="middle">'.$HTTP_USER_AGENT.' > > > '; > > > > > > > > > file_put_contents('/tmp/image.svg', $svg); > > > > > > exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png"); > > > > > > echo file_get_contents('/tmp/image.png'); > > > ?> > > > > > > -Ray Solomon > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > IE doesn't display SVG natively, and the plugins for it are pants. > However, IE does make use of its own propitiatory vector language called > VML, This is how the Cufon font replacer system works. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > Maybe svgweb (by Google) would allow you to achieve your goals: http://code.google.com/p/svgweb/ Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] session variables and SVG documents
At 10:49 AM +0100 2/3/10, Aurelie REYMUND wrote: Hello, unfortunately, it does not suite my needs. The image must be clickable. The application I'm developping reads data from a database and display the information graphically. The user must be able to click on some elements of the picture, and I have to store the information the user clicked on (session vars). I cannot tell the user not to use IE, so I have to find another solution... Regards, Aurelie Aurelie: The image must be clickable? I must not be understanding something. Anything can be made clickable, just put it in an anchor, such as: Click This The previous post mentioned using ImageMagick to convert the svg to png -- so write that script and place it in an anchor. I don't see the problem. 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 variables and SVG documents
On Wed, 2010-02-03 at 10:49 +0100, Aurelie REYMUND wrote: > Hello, > > unfortunately, it does not suite my needs. The image must be clickable. The > application I'm developping reads data from a database and display the > information graphically. The user must be able to click on some elements of > the picture, and I have to store the information the user clicked on > (session vars). I cannot tell the user not to use IE, so I have to find > another solution... > > Regards, > Aurelie > > 2010/2/1 Ray Solomon > > > From: "Aurelie REYMUND" > > Sent: Monday, February 01, 2010 3:37 AM > > To: > > Subject: [PHP] session variables and SVG documents > > > > > > Hello, > >> > >> I have the following problem with the Adobe SVG viewer: > >> I try to generate a SVG document using PHP. the following code is working > >> well under Firefox, as well as IE with ASV: > >> > >> >> > >> header("Content-type: image/svg+xml"); > >> > >> $graph_title = 'title'; > >> > >> > >> print(''); > >> $svgwidth=500; > >> $svgheight=400; > >> ?> > >> > >> >> http://www.w3.org/TR/SVG/DTD/svg10.dtd";> > >> >> xmlns="http://www.w3.org/2000/svg";> > >> This is a php-random rectangle test > >> >> srand((double) microtime() * 100); //initalizing random generator > >> for ($i = 0; $i < 20; $i+=1) { > >> $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand > >> function > >> $y = floor(rand(0,$svgheight-1)); > >> $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of > >> viewbox > >> $height = floor(rand(0,$svgheight-$y)); > >> $red = floor(rand(0,255)); > >> $blue = floor(rand(0,255)); > >> $green = floor(rand(0,255)); > >> $color = "rgb(".$red.",".$green.",".$ > >> blue.")"; > >> print "\t >> style=\"fill:$color;\"/>\n"; > >> } > >> ?> > >>>> text-anchor="middle">The servers Date and Time is: >> (strftime("%Y-%m-%d, %H:%M:%S")); ?> > >>>> text-anchor="middle">You are running: > >>>> text-anchor="middle"> > >> > >> > >> If now I want to include the session_start() at the beginning of the code, > >> in IE I got a pop-up dialog called "download file" > >> > >> What am I doing wrong ? > >> > >> Regards, > >> Aurelie > >> > >> > > > > It appears IE does not support svg yet and you need a plugin for it. > > > > However, you could also design your code differently by using Imagemagick > > to convert the svg to png. > > If that suits your needs, then use the modified code below: > > > > > > > > > header("Content-type: image/png"); > > > > $graph_title = 'title'; > > > > $svgwidth=500; > > $svgheight=400; > > > > $svg = ' > > http://www.w3.org/2000/svg";> > > This is a php-random rectangle test'; > > > > > > for ($i = 0; $i < 20; $i++) { > > > >$x = floor(rand(0,$svgwidth-1)); > >$y = floor(rand(0,$svgheight-1)); > >$width = floor(rand(0,$svgwidth-$x)); > >$height = floor(rand(0,$svgheight-$y)); > >$red = floor(rand(0,255)); > >$blue = floor(rand(0,255)); > >$green = floor(rand(0,255)); > >$color = "rgb(".$red.",".$green.",".$blue.")"; > >$svg .= "\t > height=\"$height\" style=\"fill:$color;\"/>\n"; > > } > > > > $svg .= ' > text-anchor="middle">The servers Date and Time is: '.date("Y-m-d, > > H:m:s").' > >> text-anchor="middle">You are running: > >> text-anchor="middle">'.$HTTP_USER_AGENT.' > > '; > > > > > > file_put_contents('/tmp/image.svg', $svg); > > > > exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png"); > > > > echo file_get_contents('/tmp/image.png'); > > ?> > > > > -Ray Solomon > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > IE doesn't display SVG natively, and the plugins for it are pants. However, IE does make use of its own propitiatory vector language called VML, This is how the Cufon font replacer system works. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] session variables and SVG documents
Hello, unfortunately, it does not suite my needs. The image must be clickable. The application I'm developping reads data from a database and display the information graphically. The user must be able to click on some elements of the picture, and I have to store the information the user clicked on (session vars). I cannot tell the user not to use IE, so I have to find another solution... Regards, Aurelie 2010/2/1 Ray Solomon > From: "Aurelie REYMUND" > Sent: Monday, February 01, 2010 3:37 AM > To: > Subject: [PHP] session variables and SVG documents > > > Hello, >> >> I have the following problem with the Adobe SVG viewer: >> I try to generate a SVG document using PHP. the following code is working >> well under Firefox, as well as IE with ASV: >> >> > >> header("Content-type: image/svg+xml"); >> >> $graph_title = 'title'; >> >> >> print(''); >> $svgwidth=500; >> $svgheight=400; >> ?> >> >> > http://www.w3.org/TR/SVG/DTD/svg10.dtd";> >> > xmlns="http://www.w3.org/2000/svg";> >> This is a php-random rectangle test >> > srand((double) microtime() * 100); //initalizing random generator >> for ($i = 0; $i < 20; $i+=1) { >> $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand >> function >> $y = floor(rand(0,$svgheight-1)); >> $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of >> viewbox >> $height = floor(rand(0,$svgheight-$y)); >> $red = floor(rand(0,255)); >> $blue = floor(rand(0,255)); >> $green = floor(rand(0,255)); >> $color = "rgb(".$red.",".$green.",".$ >> blue.")"; >> print "\t> style=\"fill:$color;\"/>\n"; >> } >> ?> >> > text-anchor="middle">The servers Date and Time is: > (strftime("%Y-%m-%d, %H:%M:%S")); ?> >> > text-anchor="middle">You are running: >> > text-anchor="middle"> >> >> >> If now I want to include the session_start() at the beginning of the code, >> in IE I got a pop-up dialog called "download file" >> >> What am I doing wrong ? >> >> Regards, >> Aurelie >> >> > > It appears IE does not support svg yet and you need a plugin for it. > > However, you could also design your code differently by using Imagemagick > to convert the svg to png. > If that suits your needs, then use the modified code below: > > > > header("Content-type: image/png"); > > $graph_title = 'title'; > > $svgwidth=500; > $svgheight=400; > > $svg = ' > http://www.w3.org/2000/svg";> > This is a php-random rectangle test'; > > > for ($i = 0; $i < 20; $i++) { > >$x = floor(rand(0,$svgwidth-1)); >$y = floor(rand(0,$svgheight-1)); >$width = floor(rand(0,$svgwidth-$x)); >$height = floor(rand(0,$svgheight-$y)); >$red = floor(rand(0,255)); >$blue = floor(rand(0,255)); >$green = floor(rand(0,255)); >$color = "rgb(".$red.",".$green.",".$blue.")"; >$svg .= "\t height=\"$height\" style=\"fill:$color;\"/>\n"; > } > > $svg .= ' text-anchor="middle">The servers Date and Time is: '.date("Y-m-d, > H:m:s").' >text-anchor="middle">You are running: >text-anchor="middle">'.$HTTP_USER_AGENT.' > '; > > > file_put_contents('/tmp/image.svg', $svg); > > exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png"); > > echo file_get_contents('/tmp/image.png'); > ?> > > -Ray Solomon > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] session variables and SVG documents
From: "Aurelie REYMUND" Sent: Monday, February 01, 2010 3:37 AM To: Subject: [PHP] session variables and SVG documents Hello, I have the following problem with the Adobe SVG viewer: I try to generate a SVG document using PHP. the following code is working well under Firefox, as well as IE with ASV: '); $svgwidth=500; $svgheight=400; ?> http://www.w3.org/TR/SVG/DTD/svg10.dtd";> xmlns="http://www.w3.org/2000/svg";> This is a php-random rectangle test \n"; } ?> The servers Date and Time is: You are running: If now I want to include the session_start() at the beginning of the code, in IE I got a pop-up dialog called "download file" What am I doing wrong ? Regards, Aurelie It appears IE does not support svg yet and you need a plugin for it. However, you could also design your code differently by using Imagemagick to convert the svg to png. If that suits your needs, then use the modified code below: xmlns="http://www.w3.org/2000/svg";> This is a php-random rectangle test'; for ($i = 0; $i < 20; $i++) { $x = floor(rand(0,$svgwidth-1)); $y = floor(rand(0,$svgheight-1)); $width = floor(rand(0,$svgwidth-$x)); $height = floor(rand(0,$svgheight-$y)); $red = floor(rand(0,255)); $blue = floor(rand(0,255)); $green = floor(rand(0,255)); $color = "rgb(".$red.",".$green.",".$blue.")"; $svg .= "\tstyle=\"fill:$color;\"/>\n"; } $svg .= 'text-anchor="middle">The servers Date and Time is: '.date("Y-m-d, H:m:s").' text-anchor="middle">You are running: text-anchor="middle">'.$HTTP_USER_AGENT.' '; file_put_contents('/tmp/image.svg', $svg); exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png"); echo file_get_contents('/tmp/image.png'); ?> -Ray Solomon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables and SVG documents
On Mon, 2010-02-01 at 11:37 +0100, Aurelie REYMUND wrote: > Hello, > > I have the following problem with the Adobe SVG viewer: > I try to generate a SVG document using PHP. the following code is working > well under Firefox, as well as IE with ASV: > > > header("Content-type: image/svg+xml"); > > $graph_title = 'title'; > > > print(''); > $svgwidth=500; > $svgheight=400; > ?> > > http://www.w3.org/TR/SVG/DTD/svg10.dtd";> > xmlns="http://www.w3.org/2000/svg";> > This is a php-random rectangle test > srand((double) microtime() * 100); //initalizing random generator > for ($i = 0; $i < 20; $i+=1) { > $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand > function > $y = floor(rand(0,$svgheight-1)); > $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of > viewbox > $height = floor(rand(0,$svgheight-$y)); > $red = floor(rand(0,255)); > $blue = floor(rand(0,255)); > $green = floor(rand(0,255)); > $color = "rgb(".$red.",".$green.",".$ > blue.")"; > print "\t style=\"fill:$color;\"/>\n"; > } > ?> > text-anchor="middle">The servers Date and Time is: (strftime("%Y-%m-%d, %H:%M:%S")); ?> > text-anchor="middle">You are running: > text-anchor="middle"> > > > If now I want to include the session_start() at the beginning of the code, > in IE I got a pop-up dialog called "download file" > > What am I doing wrong ? > > Regards, > Aurelie It sounds like it's the SVG plugin you're using on IE that's badly misbehaving. That said, I've not seen any plugins that correctly pass across the full headers that the browser would. I tried using sessions once to secure media files by checking for a valid login against the session id, but the plugins requesting the video clips didn't send any cookie data in the header request. As such, it might be better to not rely on it in this case. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] session variables and SVG documents
Hello, I have the following problem with the Adobe SVG viewer: I try to generate a SVG document using PHP. the following code is working well under Firefox, as well as IE with ASV: '); $svgwidth=500; $svgheight=400; ?> http://www.w3.org/TR/SVG/DTD/svg10.dtd";> http://www.w3.org/2000/svg";> This is a php-random rectangle test \n"; } ?> The servers Date and Time is: You are running: If now I want to include the session_start() at the beginning of the code, in IE I got a pop-up dialog called "download file" What am I doing wrong ? Regards, Aurelie
RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
Hi Jamie. Thanks. Good info. I knew something changed somewhere. This works like a charm in IE8..never saw the New Session option under file...me bad !! Greetings. -Original Message- From: Jaime Bozza [mailto:jbo...@mindsites.com] Sent: 20 August 2009 09:49 PM To: Leon du Plessis; 'Floyd Resler' Cc: a...@dotcontent.net; php-general@lists.php.net Subject: RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS Leon, This is really just a function of the browser. When a session cookie is created, if the browser is setup for a single instance, that's the session cookie it'll use for *any* request to that domain. This functions differently depending on what browser you're using. For example: Firefox - All windows, tabs, etc, under the same profile will use the same session. If you create profiles, you can have different sessions. IE7, IE6 - All tabs or windows opened from clicks will share the same instance/session. Starting IE from the icon will open up a "new" instance/session. This worked great if you wanted to run two different sessions at the same site/domain. Just start IE up from the icon again and you'd have a new session. IE8 - IE8 model changed, so that all browser windows, tabs, etc., run under the same frame/session, much like Firefox. Clicking the IE icon again now just keeps the same frame and thus the same session. Originally, this sounded like a big problem, but IE8 introduced a new feature - File Menu -> New Session. This will open up a new window that will be a separate frame that will not use current session cookies. Here's just one of many links, but gives some helpful hints on the IE side: http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-a nd-ie8.aspx And another: http://blogs.msdn.com/askie/archive/2009/05/08/session-management-within-int ernet-explorer-8-0.aspx One of the issues now is that if you close IE, your session does not disappear. In the past (IE7/IE6), your session would disappear if you closed a browser window that you opened yourself, but it *wouldn't* disappear if you closed a browser window that was opened by a click from Outlook or another program. This was a bit inconsistent. I won't argue whether or not their "fix" was the best way to go, but now it's at least consistent. Note - In Firefox, not even "Private Browsing" separates the session cookies. If you start Private Browsing (Firefox 3.5), log into a site, then start a new browser window from the icon (that isn't in Private Browsing mode), it shares the session cookies. (Before you ask, I just checked this to be sure.) IE8 "InPrivate Mode" is a totally separate session, cookies and all. This could possibly be another way for you to run multiple sessions against the same domain. OTOH, multiple InPrivate sessions running at the same time share the same frame, so they share the same session, so it would only be good for a single new session. If you need more, just use File - New Session. Jaime > -Original Message- > From: Leon du Plessis [mailto:l...@dsgnit.com] > Sent: Thursday, August 20, 2009 8:16 AM > To: 'Floyd Resler' > Cc: a...@dotcontent.net; php-general@lists.php.net > Subject: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS > > It is just strange that I have this "condition" now...maybe I missed it > a > year ago ? > > >> "Having a different session start up for each window for tab would > be a > major pain." > > Why? > > People must please try and understand what I mean by NEW. It does not > apply > to windows/tabs being opened from a link or request. > > Imho, keeping the session per domain "sounds" wrong, it does not mean > it is. > It would have been nice if: > > Browser/tab one -> my login detail container A. > Browser/tab two -> my admin login container B. > (tabs/windows opened from browser one, then inherits container A > naturally) > (Closing browser one, then destroys container A then naturally only) > > NOT > > Domain.com -> one session container only. > > Heck, I am surprised it works that way at all cause it "sounds" like > the > domain can then only handle one user a time if arrays are not used or > profiles not created on FF no matter where the request come from, but, > then > I am obviously missing something in this respect as stated. When I have > time > I will reconstruct this concept again. > > Thanks anyway guys. I received some helpful advise for future > reference. > > But please..I do not, like many others, want to start a war. I am ok > with > things how they are. We can put this thing to rest. > > -Original Message- > From: Floyd Resler [mailto:fres...@adex-intl.c
RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
Leon, This is really just a function of the browser. When a session cookie is created, if the browser is setup for a single instance, that's the session cookie it'll use for *any* request to that domain. This functions differently depending on what browser you're using. For example: Firefox - All windows, tabs, etc, under the same profile will use the same session. If you create profiles, you can have different sessions. IE7, IE6 - All tabs or windows opened from clicks will share the same instance/session. Starting IE from the icon will open up a "new" instance/session. This worked great if you wanted to run two different sessions at the same site/domain. Just start IE up from the icon again and you'd have a new session. IE8 - IE8 model changed, so that all browser windows, tabs, etc., run under the same frame/session, much like Firefox. Clicking the IE icon again now just keeps the same frame and thus the same session. Originally, this sounded like a big problem, but IE8 introduced a new feature - File Menu -> New Session. This will open up a new window that will be a separate frame that will not use current session cookies. Here's just one of many links, but gives some helpful hints on the IE side: http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-and-ie8.aspx And another: http://blogs.msdn.com/askie/archive/2009/05/08/session-management-within-internet-explorer-8-0.aspx One of the issues now is that if you close IE, your session does not disappear. In the past (IE7/IE6), your session would disappear if you closed a browser window that you opened yourself, but it *wouldn't* disappear if you closed a browser window that was opened by a click from Outlook or another program. This was a bit inconsistent. I won't argue whether or not their "fix" was the best way to go, but now it's at least consistent. Note - In Firefox, not even "Private Browsing" separates the session cookies. If you start Private Browsing (Firefox 3.5), log into a site, then start a new browser window from the icon (that isn't in Private Browsing mode), it shares the session cookies. (Before you ask, I just checked this to be sure.) IE8 "InPrivate Mode" is a totally separate session, cookies and all. This could possibly be another way for you to run multiple sessions against the same domain. OTOH, multiple InPrivate sessions running at the same time share the same frame, so they share the same session, so it would only be good for a single new session. If you need more, just use File - New Session. Jaime > -Original Message- > From: Leon du Plessis [mailto:l...@dsgnit.com] > Sent: Thursday, August 20, 2009 8:16 AM > To: 'Floyd Resler' > Cc: a...@dotcontent.net; php-general@lists.php.net > Subject: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS > > It is just strange that I have this "condition" now...maybe I missed it > a > year ago ? > > >> "Having a different session start up for each window for tab would > be a > major pain." > > Why? > > People must please try and understand what I mean by NEW. It does not > apply > to windows/tabs being opened from a link or request. > > Imho, keeping the session per domain "sounds" wrong, it does not mean > it is. > It would have been nice if: > > Browser/tab one -> my login detail container A. > Browser/tab two -> my admin login container B. > (tabs/windows opened from browser one, then inherits container A > naturally) > (Closing browser one, then destroys container A then naturally only) > > NOT > > Domain.com -> one session container only. > > Heck, I am surprised it works that way at all cause it "sounds" like > the > domain can then only handle one user a time if arrays are not used or > profiles not created on FF no matter where the request come from, but, > then > I am obviously missing something in this respect as stated. When I have > time > I will reconstruct this concept again. > > Thanks anyway guys. I received some helpful advise for future > reference. > > But please..I do not, like many others, want to start a war. I am ok > with > things how they are. We can put this thing to rest. > > -Original Message- > From: Floyd Resler [mailto:fres...@adex-intl.com] > Sent: 20 August 2009 02:25 PM > To: Leon du Plessis > Cc: a...@dotcontent.net; php-general@lists.php.net > Subject: Re: [PHP] SESSIONS lost sometimes > > Leon, > Sessions are used on a per-domain basis. So, no matter how many > windows or tabs you have open for mydomain.com it will be the same > session for all. Having a different session start up for each window > or t
Re: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
On Thu, 2009-08-20 at 15:16 +0200, Leon du Plessis wrote: > It is just strange that I have this "condition" now...maybe I missed it a > year ago ? > > >> "Having a different session start up for each window for tab would be a > major pain." > > Why? > > People must please try and understand what I mean by NEW. It does not apply > to windows/tabs being opened from a link or request. > > Imho, keeping the session per domain "sounds" wrong, it does not mean it is. > It would have been nice if: > > Browser/tab one -> my login detail container A. > Browser/tab two -> my admin login container B. > (tabs/windows opened from browser one, then inherits container A naturally) > (Closing browser one, then destroys container A then naturally only) > > NOT > > Domain.com -> one session container only. > > Heck, I am surprised it works that way at all cause it "sounds" like the > domain can then only handle one user a time if arrays are not used or > profiles not created on FF no matter where the request come from, but, then > I am obviously missing something in this respect as stated. When I have time > I will reconstruct this concept again. > > Thanks anyway guys. I received some helpful advise for future reference. > > But please..I do not, like many others, want to start a war. I am ok with > things how they are. We can put this thing to rest. > > -Original Message- > From: Floyd Resler [mailto:fres...@adex-intl.com] > Sent: 20 August 2009 02:25 PM > To: Leon du Plessis > Cc: a...@dotcontent.net; php-general@lists.php.net > Subject: Re: [PHP] SESSIONS lost sometimes > > Leon, > Sessions are used on a per-domain basis. So, no matter how many > windows or tabs you have open for mydomain.com it will be the same > session for all. Having a different session start up for each window > or tab would be a major pain. If you needed to keep track of a user > ID, for example, you wouldn't be able to. As already mentioned you > can use different browsers. You can also set up sub-domains which > would each have their own sessions. > > Take care, > Floyd > > On Aug 20, 2009, at 4:26 AM, Leon du Plessis wrote: > > > ">> It's not an issue, it's a feature." > > > > Thanks Arno...but it is a pain also. > > If I work with user A in Tab1 (window1), I want to work with user B > > separately in Tab2. When user in Tab2 logs off, I still want user A > > to work, > > and not suddenly have to re-login. Same with bank. If I work with my > > company > > account, then my personal account must not become an issue because I > > am on > > the same machine and site. > > > > I have no issue with using FF and IE to do testing as that takes > > care of > > browser compatibility testing at the same time :-), but I think when > > you > > start a new session with new values, it should be kept under that > > window/tab > > alone. Cookies can take care of more details, but my opinion is data > > should > > never be affected across windows/tabs unless the same user is logged > > in on > > botheven then I would expect PHP to keep data per session. Maybe > > it goes > > beyond being an IE or FF issue..the questiojn is...will PHP allow > > variables > > from session A become corrupted when session B is in progress when > > they > > should actually be handled seperately? > > > > In the end I think it is something I do wrong in PHP with the SESSION > > variables and how I clear themif so...I don't think PHP should > > allow > > clearing SESSION variables from other sessions. > > > > -Original Message- > > From: Arno Kuhl [mailto:ak...@telkomsa.net] > > Sent: 20 August 2009 10:03 AM > > To: 'Leon du Plessis'; php-general@lists.php.net > > Subject: RE: [PHP] SESSIONS lost sometimes > > > > -Original Message- > > From: Leon du Plessis [mailto:l...@dsgnit.com] > > Sent: 20 August 2009 09:44 AM > > To: php-general@lists.php.net > > Subject: RE: [PHP] SESSIONS lost sometimes > > > > Since we are on the subject: I have the following similar problem: > > > > When testing page on internet explorer, I find that one tab's > > variables can > > affect another tab's variables. Thus when having the same web-site > > open and > > using SESSION variables but for different users, Internet explorer can > > become "disorientated". This also "sometimes" happen when I have two > > separate browsing windows open with Internet Explorer for the same > > site. > > > > I have yet to determine if this is an internet explorer, or PHP or > > combination of the two that is causing this condition. > > > > To my understanding _SESSION variables should be maintained per > > session, tab > > or window. If this has been addressed already, my apologies, but > > thought it > > worthwhile to mention. > > > > If someone perhaps have a solution or can confirm this as a known > > issue and > > maybe is the same or related to Angelo's problem? > > > > > > > > If different bro
[PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
It is just strange that I have this "condition" now...maybe I missed it a year ago ? >> "Having a different session start up for each window for tab would be a major pain." Why? People must please try and understand what I mean by NEW. It does not apply to windows/tabs being opened from a link or request. Imho, keeping the session per domain "sounds" wrong, it does not mean it is. It would have been nice if: Browser/tab one -> my login detail container A. Browser/tab two -> my admin login container B. (tabs/windows opened from browser one, then inherits container A naturally) (Closing browser one, then destroys container A then naturally only) NOT Domain.com -> one session container only. Heck, I am surprised it works that way at all cause it "sounds" like the domain can then only handle one user a time if arrays are not used or profiles not created on FF no matter where the request come from, but, then I am obviously missing something in this respect as stated. When I have time I will reconstruct this concept again. Thanks anyway guys. I received some helpful advise for future reference. But please..I do not, like many others, want to start a war. I am ok with things how they are. We can put this thing to rest. -Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: 20 August 2009 02:25 PM To: Leon du Plessis Cc: a...@dotcontent.net; php-general@lists.php.net Subject: Re: [PHP] SESSIONS lost sometimes Leon, Sessions are used on a per-domain basis. So, no matter how many windows or tabs you have open for mydomain.com it will be the same session for all. Having a different session start up for each window or tab would be a major pain. If you needed to keep track of a user ID, for example, you wouldn't be able to. As already mentioned you can use different browsers. You can also set up sub-domains which would each have their own sessions. Take care, Floyd On Aug 20, 2009, at 4:26 AM, Leon du Plessis wrote: > ">> It's not an issue, it's a feature." > > Thanks Arno...but it is a pain also. > If I work with user A in Tab1 (window1), I want to work with user B > separately in Tab2. When user in Tab2 logs off, I still want user A > to work, > and not suddenly have to re-login. Same with bank. If I work with my > company > account, then my personal account must not become an issue because I > am on > the same machine and site. > > I have no issue with using FF and IE to do testing as that takes > care of > browser compatibility testing at the same time :-), but I think when > you > start a new session with new values, it should be kept under that > window/tab > alone. Cookies can take care of more details, but my opinion is data > should > never be affected across windows/tabs unless the same user is logged > in on > botheven then I would expect PHP to keep data per session. Maybe > it goes > beyond being an IE or FF issue..the questiojn is...will PHP allow > variables > from session A become corrupted when session B is in progress when > they > should actually be handled seperately? > > In the end I think it is something I do wrong in PHP with the SESSION > variables and how I clear themif so...I don't think PHP should > allow > clearing SESSION variables from other sessions. > > -Original Message- > From: Arno Kuhl [mailto:ak...@telkomsa.net] > Sent: 20 August 2009 10:03 AM > To: 'Leon du Plessis'; php-general@lists.php.net > Subject: RE: [PHP] SESSIONS lost sometimes > > -Original Message- > From: Leon du Plessis [mailto:l...@dsgnit.com] > Sent: 20 August 2009 09:44 AM > To: php-general@lists.php.net > Subject: RE: [PHP] SESSIONS lost sometimes > > Since we are on the subject: I have the following similar problem: > > When testing page on internet explorer, I find that one tab's > variables can > affect another tab's variables. Thus when having the same web-site > open and > using SESSION variables but for different users, Internet explorer can > become "disorientated". This also "sometimes" happen when I have two > separate browsing windows open with Internet Explorer for the same > site. > > I have yet to determine if this is an internet explorer, or PHP or > combination of the two that is causing this condition. > > To my understanding _SESSION variables should be maintained per > session, tab > or window. If this has been addressed already, my apologies, but > thought it > worthwhile to mention. > > If someone perhaps have a solution or can confirm this as a known > issue and > maybe is the same or related to Angelo's problem? > > > > If different browser windows/tabs on the same client-side computer > didn't > share session info then you'd get the effect of being able to log > onto a > site with one browser window, but find in a second browser window > that you > were not yet logged on. Experience will tell you that you're logged > on in > both brows
Re: [PHP] session variables - help RESOLVED
Thanks everyone for your help, I finally got it working. For those that were curious, my writeResultRow() function was not naming the input fields properly, so the SESSION variables could not be updated properly. I had to add an array item for each show, an id, then call the id to name the inputs with. On Fri, Aug 14, 2009 at 11:13 AM, Ben Dunlap wrote: > Great, hope it helps! -Ben > > On Fri, Aug 14, 2009 at 10:52 AM, Allen McCabe > wrote: > > This is an EXCELLENT idea. > > >
Re: [PHP] session variables - help
> Thanks all for your patience! I will work on this today and write back with > any further questions I can't figure out on my own. And if anyone has any > advice I will be checking my email regularly. If you've already tried this with no luck, please ignore -- but you might speed up the whole process by stepping aside from the "real" code briefly, starting fresh in an empty directory, and just putting together a handful of extremely simple scripts with the single goal of entering one value, updating it, and then doing some final pseudo-processing on the updated value. Then, you could step it up a bit by by adding a second value that gets entered at the beginning, and cannot be updated in the middle but must be preserved through to the end. Doing all this might help clarify the basic flow of the system and enable you to simplify its structure before going back and tackling the real code. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables - help
On Fri, Aug 14, 2009 at 12:25 PM, Allen McCabe wrote: > Thank you all for your responses. > > Mike. > > I like the ii option better, mostly because I already have most of that in > place (ie. order posts to process, and process has editable fields and > hidden fields with the remaining complimentary values). > Martin suggested I use the following code for my update script (which is > posted to via the process page): > > [code] > > foreach($_POST as $key => $value) >if( '0' == $value || '' == $value ) >{ >/*if*/ session_is_registered( $key ) && >session_unregister( $key ); >} > > [/code] > > I am not following the logic on the above code very well, but is this > indeed > a better option? And is not session_*whatever deprecated? The reason I am > using $_SESSION is because it seems that php 6 will use solely this method, > and it currently works with php 5. The other reason I am using it is so > that > I can keep the variables stored elsewhere for whenever I need them; I don't > want to have to juggle all the information with POST and hidden inputs > unless it will work seamlessly, and be ready for update at a later date (if > I move to using a database to store show information, or when php 6 is > mainstream). > > Keep in mind that once I get the update feature working, I need the process > page to have a final submit button that will insert the order into a > database table AND send a notification email to myself (and an email to the > user). Am I setting myself up for failure with this udate order option? I > ask because the update feature relies on a form, and are not forms limited > to one submit button? > > Thanks all for your patience! I will work on this today and write back with > any further questions I can't figure out on my own. And if anyone has any > advice I will be checking my email regularly. > > Allen > On Fri, Aug 14, 2009 at 7:52 AM, Ford, Mike wrote: > > > > -Original Message- > > > From: Allen McCabe [mailto:allenmcc...@gmail.com] > > > Sent: 14 August 2009 06:58 > > > > > > Here is some more complete code: > > > > > > [code = order_process.php] > > > > > > > > session_start(); > > > // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION > > > foreach($_POST as $k=>$v) { > > > $_SESSION[$k]=$v; > > > } > > > > > > $thisPage="AFY"; //NAVIGATION PURPOSES > > > include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES; > > > POPULATES > > > ORDER FORM > > > ?> > > > > > > . . . > > > > > > > > > > > > > Er wait, no! Sessions and hidden form fields are generally alternative > > solutions to the same problem -- you shouldn't be putting the same values > > both in the session and in hidden form fields. In this case, I'm > beginning > > to suspect that the hidden fields are the better solution, but there is a > > certain amount of personal preference in this. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > > > . . . > > > > > > > > > > > function findTotalCost($b, $c) { > > > $total = $b * $c; > > > return $total; > > > } > > > > > > function writeResultRow($a, $b, $c, $d, $e, $f) { > > > if($a != '') { > > > echo "\n\n\t"; > > > echo "".$b."".$c."".$d.""; > > > echo "".$e." > > value='".$a."' > > > name='".$a."' id='".$a."' size='2' > > > />=\$".$f.""; > > > echo ""; > > > } > > > } > > > > > > //SETS $Total_show_01 to PRICE * QUANTITY > > > //FORMATS TOTAL > > > //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES > > > $Total_show_01 = findTotalCost($shows['show_01']['price'], > > > $_SESSION['show_01_qty']); > > > $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', ''); > > > writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'], > > > $shows['show_01']['date'], $shows['show_01']['time'], > > > $shows['show_01']['price'],$Total_show_01_fmtd); > > > > > > //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38) > > > > > > ?> > > > . . . > > > > > > > > > > > > [/code] > > > > If I'm reading what you want to do correctly, it seems to me there are > two > > obvious approaches to this: > > > > (i) Have a single form which posts back to itself, showing all the show > > information and requested quantities and calculated result fields (such > as > > total cost); initially, this will have the calculated fields not > displaying > > anything, and these will be (re)populated at each Update. Using this > > method, all your values are contained solely within the $_POST array. > > > > (ii) Have your initial form post to the process form, which then also > posts > > to itself on Update. This process form will have visible fields only for > > values which can be changed, but *must* then contain hidden fields for > all > > the other values which were originally passed in the $_POST array. This > > arrangement means that the process form always receives a full complement > of > > values in the $_POST array -- either from the original form, or from >
Re: [PHP] session variables - help
Thank you all for your responses. Mike. I like the ii option better, mostly because I already have most of that in place (ie. order posts to process, and process has editable fields and hidden fields with the remaining complimentary values). Martin suggested I use the following code for my update script (which is posted to via the process page): [code] foreach($_POST as $key => $value) if( '0' == $value || '' == $value ) { /*if*/ session_is_registered( $key ) && session_unregister( $key ); } [/code] I am not following the logic on the above code very well, but is this indeed a better option? And is not session_*whatever deprecated? The reason I am using $_SESSION is because it seems that php 6 will use solely this method, and it currently works with php 5. The other reason I am using it is so that I can keep the variables stored elsewhere for whenever I need them; I don't want to have to juggle all the information with POST and hidden inputs unless it will work seamlessly, and be ready for update at a later date (if I move to using a database to store show information, or when php 6 is mainstream). Keep in mind that once I get the update feature working, I need the process page to have a final submit button that will insert the order into a database table AND send a notification email to myself (and an email to the user). Am I setting myself up for failure with this udate order option? I ask because the update feature relies on a form, and are not forms limited to one submit button? Thanks all for your patience! I will work on this today and write back with any further questions I can't figure out on my own. And if anyone has any advice I will be checking my email regularly. Allen On Fri, Aug 14, 2009 at 7:52 AM, Ford, Mike wrote: > > -Original Message- > > From: Allen McCabe [mailto:allenmcc...@gmail.com] > > Sent: 14 August 2009 06:58 > > > > Here is some more complete code: > > > > [code = order_process.php] > > > > > session_start(); > > // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION > > foreach($_POST as $k=>$v) { > > $_SESSION[$k]=$v; > > } > > > > $thisPage="AFY"; //NAVIGATION PURPOSES > > include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES; > > POPULATES > > ORDER FORM > > ?> > > > > . . . > > > > > > > > Er wait, no! Sessions and hidden form fields are generally alternative > solutions to the same problem -- you shouldn't be putting the same values > both in the session and in hidden form fields. In this case, I'm beginning > to suspect that the hidden fields are the better solution, but there is a > certain amount of personal preference in this. > > > > > > > > > > > > > > > > > > > > /> > > > > . . . > > > > > > > function findTotalCost($b, $c) { > > $total = $b * $c; > > return $total; > > } > > > > function writeResultRow($a, $b, $c, $d, $e, $f) { > > if($a != '') { > > echo "\n\n\t"; > > echo "".$b."".$c."".$d.""; > > echo "".$e." > value='".$a."' > > name='".$a."' id='".$a."' size='2' > > />=\$".$f.""; > > echo ""; > > } > > } > > > > //SETS $Total_show_01 to PRICE * QUANTITY > > //FORMATS TOTAL > > //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES > > $Total_show_01 = findTotalCost($shows['show_01']['price'], > > $_SESSION['show_01_qty']); > > $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', ''); > > writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'], > > $shows['show_01']['date'], $shows['show_01']['time'], > > $shows['show_01']['price'],$Total_show_01_fmtd); > > > > //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38) > > > > ?> > > . . . > > > > > > > > [/code] > > If I'm reading what you want to do correctly, it seems to me there are two > obvious approaches to this: > > (i) Have a single form which posts back to itself, showing all the show > information and requested quantities and calculated result fields (such as > total cost); initially, this will have the calculated fields not displaying > anything, and these will be (re)populated at each Update. Using this > method, all your values are contained solely within the $_POST array. > > (ii) Have your initial form post to the process form, which then also posts > to itself on Update. This process form will have visible fields only for > values which can be changed, but *must* then contain hidden fields for all > the other values which were originally passed in the $_POST array. This > arrangement means that the process form always receives a full complement of > values in the $_POST array -- either from the original form, or from hidden > fields posted back to itself. > > This is all just coming off the top of my head, and I'm sure there are > improvements/other solutions to be offered. Hope this will give you some > things to think about, and maybe a pointer or two towards a satisfactory > solution. > > > Cheers! > > Mike > -- > Mike Ford, > Electronic Information D
RE: [PHP] session variables - help
> -Original Message- > From: Allen McCabe [mailto:allenmcc...@gmail.com] > Sent: 14 August 2009 06:58 > > Here is some more complete code: > > [code = order_process.php] > > session_start(); > // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION > foreach($_POST as $k=>$v) { > $_SESSION[$k]=$v; > } > > $thisPage="AFY"; //NAVIGATION PURPOSES > include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES; > POPULATES > ORDER FORM > ?> > > . . . > > > Er wait, no! Sessions and hidden form fields are generally alternative solutions to the same problem -- you shouldn't be putting the same values both in the session and in hidden form fields. In this case, I'm beginning to suspect that the hidden fields are the better solution, but there is a certain amount of personal preference in this. > > > > > > > > > /> > > . . . > > > function findTotalCost($b, $c) { > $total = $b * $c; > return $total; > } > > function writeResultRow($a, $b, $c, $d, $e, $f) { > if($a != '') { > echo "\n\n\t"; > echo "".$b."".$c."".$d.""; > echo "".$e." value='".$a."' > name='".$a."' id='".$a."' size='2' > />=\$".$f.""; > echo ""; > } > } > > //SETS $Total_show_01 to PRICE * QUANTITY > //FORMATS TOTAL > //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES > $Total_show_01 = findTotalCost($shows['show_01']['price'], > $_SESSION['show_01_qty']); > $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', ''); > writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'], > $shows['show_01']['date'], $shows['show_01']['time'], > $shows['show_01']['price'],$Total_show_01_fmtd); > > //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38) > > ?> > . . . > > > > [/code] If I'm reading what you want to do correctly, it seems to me there are two obvious approaches to this: (i) Have a single form which posts back to itself, showing all the show information and requested quantities and calculated result fields (such as total cost); initially, this will have the calculated fields not displaying anything, and these will be (re)populated at each Update. Using this method, all your values are contained solely within the $_POST array. (ii) Have your initial form post to the process form, which then also posts to itself on Update. This process form will have visible fields only for values which can be changed, but *must* then contain hidden fields for all the other values which were originally passed in the $_POST array. This arrangement means that the process form always receives a full complement of values in the $_POST array -- either from the original form, or from hidden fields posted back to itself. This is all just coming off the top of my head, and I'm sure there are improvements/other solutions to be offered. Hope this will give you some things to think about, and maybe a pointer or two towards a satisfactory solution. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] session variables - help
> -Original Message- > From: Ford, Mike [mailto:m.f...@leedsmet.ac.uk] > Sent: 14 August 2009 11:45 > > Now, here is the update_order.php code in entirety: > > > > [code] > > > > > session_start(); > > foreach ($_SESSION as $var => $val) { > > if ($val == "0") { > > unset($_SESSION[$var]); > > } elseif ($val == '') { > > unset($_SESSION[$var]); > > } else { > > $val = $_SESSION[$var]; > > That line is back-to-front -- you're assigning the current value in > the session to $val, which is then immediately thrown away as the > foreach loop starts a new iteration. What you mean is > $_SESSION[$var] = $val. No, wait a minute, hold your foot up! I was so focussed on the strange assignment that I didn't read the whole thing properly. What you're *actually* doing here is -- er, well, totally not what you want to, I suspect! Having re-read the message I responded to, I'm going to go back to it and post another response Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] session variables - help
> -Original Message- > From: Allen McCabe [mailto:allenmcc...@gmail.com] > Sent: 14 August 2009 06:58 > My ai with using unset($var) in update_order.php is to set the > SESSION > variable for an item to ' ' (empty) so that it would not show up on > the > order summary (because my writeResultRow() function will only write > a row if > that variable is greater than 0). > > I just can't figure out what I'm missing here. Before I received > your > response, I made a few changes to my code, which helped streamline > the > calculating parts (grabbing values from SESSION instead of POST, and > now > when I update order_summary, the values will remain because it pulls > them > from the SESSION). > > I want to edit the values in the SESSION, so that when > update_order.php > redirects to order_process.php, the values are changed, and if > applicable, > an item is removed from the html table (if the quantity is less than > 1). > > Here is some more complete code: > > [code = order_process.php] > > session_start(); > // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION > foreach($_POST as $k=>$v) { > $_SESSION[$k]=$v; > } This has just destroyed anything that was previously in the session, so if you're recycling from the update_order.php script, you've just thrown away whatever that script did! You need to make this conditional on having arrived here from the initial form -- various ways you could do that, but I leave you to figure that one out. (Also, personally, if I were doing this at all, I would just copy the array as a single entity: $_SESSION['_POST'] = $_POST; and then reference individual elements through that as, e.g., $_SESSION['_POST']['School']. That's probably a matter of personal style as much as anything, but gives you another way to think about.) [ . . . . ] > > > function findTotalCost($b, $c) { > $total = $b * $c; > return $total; > } > > function writeResultRow($a, $b, $c, $d, $e, $f) { > if($a != '') { > echo "\n\n\t"; > echo "".$b."".$c."".$d.""; > echo "".$e." value='".$a."' > name='".$a."' id='".$a."' size='2' > />=\$".$f.""; > echo ""; > } > } > > //SETS $Total_show_01 to PRICE * QUANTITY > //FORMATS TOTAL > //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES > $Total_show_01 = findTotalCost($shows['show_01']['price'], > $_SESSION['show_01_qty']); > $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', ''); > writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'], > $shows['show_01']['date'], $shows['show_01']['time'], > $shows['show_01']['price'],$Total_show_01_fmtd); > > //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38) AARRRGHHH!! This cries out for an array-based solution -- repeating near-identical code that many times is totally ludicrous, and should be a major clue that you need to refactor. You'll have to forgo using indexes like ['show_01'] and use straight integers, but the massive reduction in repetitive code (and hence far fewer opportunities for mistakes!) will be well worth it. Something like: for ($i=1; $i<=38; ++$i): $Total[$i] = findTotalCost($shows[$i]['price'], $_SESSION['qty'][$i]); $Total_fmtd[$i] = number_format($Total[$i], 2, '.', ''); writeResultRow($_SESSION['qty'][$i], $shows[$i]['title'], $shows[$i]['date'], $shows[$i]['time'], $shows[$i]['price'],$Total_fmtd[$i]); endfor; [ . . . . ] > Now, here is the update_order.php code in entirety: > > [code] > > session_start(); > foreach ($_SESSION as $var => $val) { > if ($val == "0") { > unset($_SESSION[$var]); > } elseif ($val == '') { > unset($_SESSION[$var]); > } else { > $val = $_SESSION[$var]; That line is back-to-front -- you're assigning the current value in the session to $val, which is then immediately thrown away as the foreach loop starts a new iteration. What you mean is $_SESSION[$var] = $val. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables - help
On Fri, 2009-08-14 at 10:05 +0200, Ralph Deffke wrote: > well thanks good they are far away then, but the problem is ur client, i > didnt find anybody giving me the permission to beat his customers > > "Ashley Sheridan" wrote in message > news:1250236989.2344.10.ca...@localhost... > > On Fri, 2009-08-14 at 09:55 +0200, Ralph Deffke wrote: > > > user often leave > > > forms open for hours and then submit them > > > > These users should be taken out and beaten over the head with their > > keyboards! > > > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > Beat them hard enough and they tend to forget who did it... My life would be so much easier without end users! Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables - help
well thanks good they are far away then, but the problem is ur client, i didnt find anybody giving me the permission to beat his customers "Ashley Sheridan" wrote in message news:1250236989.2344.10.ca...@localhost... > On Fri, 2009-08-14 at 09:55 +0200, Ralph Deffke wrote: > > user often leave > > forms open for hours and then submit them > > These users should be taken out and beaten over the head with their > keyboards! > > Thanks, > Ash > http://www.ashleysheridan.co.uk > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables - help
On Fri, 2009-08-14 at 09:55 +0200, Ralph Deffke wrote: > user often leave > forms open for hours and then submit them These users should be taken out and beaten over the head with their keyboards! Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables - help
I'm realy sorry for u, but the reason for no answers is ur concept. may be some rules will help u and I recommend u to think to spend the time to rewrite the whole code. Im shure u will solve the problem then: first dont use the global arrays directly. pick the values u need and put them in reasonable types of variables. build the business logic on these variables and if u feel like put the results in well readable new ones then populate the presentation in the required htmls this will give u an more structured code, easier to debug and more fun for the group to help u I still dont understand why u use the $_SESSION variable. user often leave forms open for hours and then submit them. u can not expect a user to end a job in the livecycle of the session. thats what hidden form fields are made for. the $_session is for member like things and applications with security issues where u can expect the user to finish things in a certain time or u restart the whole. "Allen McCabe" wrote in message news:657acef20908132257x630719e1g4ecddcdff9492...@mail.gmail.com... > Ben, > > First of all, I thank you for your time and help. > > My ai with using unset($var) in update_order.php is to set the SESSION > variable for an item to ' ' (empty) so that it would not show up on the > order summary (because my writeResultRow() function will only write a row if > that variable is greater than 0). > > I just can't figure out what I'm missing here. Before I received your > response, I made a few changes to my code, which helped streamline the > calculating parts (grabbing values from SESSION instead of POST, and now > when I update order_summary, the values will remain because it pulls them > from the SESSION). > > I want to edit the values in the SESSION, so that when update_order.php > redirects to order_process.php, the values are changed, and if applicable, > an item is removed from the html table (if the quantity is less than 1). > > Here is some more complete code: > > [code = order_process.php] > > session_start(); > // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION > foreach($_POST as $k=>$v) { > $_SESSION[$k]=$v; > } > > $thisPage="AFY"; //NAVIGATION PURPOSES > include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES; POPULATES > ORDER FORM > ?> > > . . . > > > > > > > > > > > > /> > > . . . > > > function findTotalCost($b, $c) { > $total = $b * $c; > return $total; > } > > function writeResultRow($a, $b, $c, $d, $e, $f) { > if($a != '') { > echo "\n\n\t"; > echo "".$b."".$c."".$d.""; > echo "".$e." name='".$a."' id='".$a."' size='2' />=\$".$f.""; > echo ""; > } > } > > //SETS $Total_show_01 to PRICE * QUANTITY > //FORMATS TOTAL > //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES > $Total_show_01 = findTotalCost($shows['show_01']['price'], > $_SESSION['show_01_qty']); > $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', ''); > writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'], > $shows['show_01']['date'], $shows['show_01']['time'], > $shows['show_01']['price'],$Total_show_01_fmtd); > > //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38) > > ?> > . . . > > > > [/code] > > Now, here is the update_order.php code in entirety: > > [code] > > session_start(); > foreach ($_SESSION as $var => $val) { > if ($val == "0") { > unset($_SESSION[$var]); > } elseif ($val == '') { > unset($_SESSION[$var]); > } else { > $val = $_SESSION[$var]; > > } > } > header("Location: order_process.php"); > > //NOTICE I FIXED THE LOCATION OF THE header() FUNCTION > //BUT IT STILL DOES NOT UPDATE > > ?> > > [/code] > > If you're still with me, I thank you. I removed all the styling elements > from the html to make it easier for you (and me) to see what it says. I have > invested many hours into this, and have generated many many lines of code, > but I hope what I gave you is sufficient, while not being overwhelming at > this hour. > > Thank you very much for your help thus far, anything else would be greatly > appreciated. > > > On Thu, Aug 13, 2009 at 5:56 PM, Ben Dunlap wrote: > > > > > > >> I have the following code for order_update.php: > >> > >> [code] > >> > >> session_start(); > >> extract($_POST); > >> foreach ($_POST as $var => $val) { > >> if ($val > 0) { > >> $_SESSION[$var] = $val; > >> } else { > >> unset($var); > >> > >> } > >> header("Location: order_process.php"); > >> } > >> > >> [/code] > >> > >> This is not working, however, and it just loads order_process.php with no > >> values for the varaibles, as if I just refreshed the page with no > >> sessions. > > > > > > Maybe you left it out but I didn't see any place where you used $_SESSION > > in order_process.php. Also, your redirect in order_update.php appears to be > > inside your foreach loop, which would definitely mess things right up -- but > > maybe that was just a typo in your email? > > > > Otherwise the logic in order_update.php looks OK, but th
Re: [PHP] session variables - help
Ben, First of all, I thank you for your time and help. My ai with using unset($var) in update_order.php is to set the SESSION variable for an item to ' ' (empty) so that it would not show up on the order summary (because my writeResultRow() function will only write a row if that variable is greater than 0). I just can't figure out what I'm missing here. Before I received your response, I made a few changes to my code, which helped streamline the calculating parts (grabbing values from SESSION instead of POST, and now when I update order_summary, the values will remain because it pulls them from the SESSION). I want to edit the values in the SESSION, so that when update_order.php redirects to order_process.php, the values are changed, and if applicable, an item is removed from the html table (if the quantity is less than 1). Here is some more complete code: [code = order_process.php] $v) { $_SESSION[$k]=$v; } $thisPage="AFY"; //NAVIGATION PURPOSES include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES; POPULATES ORDER FORM ?> . . . . . . \n\t"; echo "".$b."".$c."".$d.""; echo "".$e." =\$".$f.""; echo ""; } } //SETS $Total_show_01 to PRICE * QUANTITY //FORMATS TOTAL //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES $Total_show_01 = findTotalCost($shows['show_01']['price'], $_SESSION['show_01_qty']); $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', ''); writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'], $shows['show_01']['date'], $shows['show_01']['time'], $shows['show_01']['price'],$Total_show_01_fmtd); //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38) ?> . . . [/code] Now, here is the update_order.php code in entirety: [code] $val) { if ($val == "0") { unset($_SESSION[$var]); } elseif ($val == '') { unset($_SESSION[$var]); } else { $val = $_SESSION[$var]; } } header("Location: order_process.php"); //NOTICE I FIXED THE LOCATION OF THE header() FUNCTION //BUT IT STILL DOES NOT UPDATE ?> [/code] If you're still with me, I thank you. I removed all the styling elements from the html to make it easier for you (and me) to see what it says. I have invested many hours into this, and have generated many many lines of code, but I hope what I gave you is sufficient, while not being overwhelming at this hour. Thank you very much for your help thus far, anything else would be greatly appreciated. On Thu, Aug 13, 2009 at 5:56 PM, Ben Dunlap wrote: > > >> I have the following code for order_update.php: >> >> [code] >> >> session_start(); >> extract($_POST); >> foreach ($_POST as $var => $val) { >> if ($val > 0) { >> $_SESSION[$var] = $val; >> } else { >> unset($var); >> >> } >> header("Location: order_process.php"); >> } >> >> [/code] >> >> This is not working, however, and it just loads order_process.php with no >> values for the varaibles, as if I just refreshed the page with no >> sessions. > > > Maybe you left it out but I didn't see any place where you used $_SESSION > in order_process.php. Also, your redirect in order_update.php appears to be > inside your foreach loop, which would definitely mess things right up -- but > maybe that was just a typo in your email? > > Otherwise the logic in order_update.php looks OK, but there are a few side > notes that jumped out: > > 1. I'm not seeing why you used "extract($_POST)" in order_update.php. Right > after the extract() call, you iterate through $_POST with a foreach loop, so > what's the purpose of calling extract()? Is there more code that you left > out? > > 2. Calling "extract($_POST)" is dangerous. The PHP manual warns against it, > although without giving much of an explanation: > > http://us2.php.net/manual/en/function.extract.php > > Apart from making it difficult to filter the input you're expecting to see, > "extract($_POST)" also allows a malicious end-user to define any variable of > his choosing and to overwrite any variables that you may have defined in the > script before the extract() call. > > I like to use filter_input() to read the values of POST variables. > > By much the same token, you'll want to escape $a, etc., in your > writeResultRow() function, with something like htmlentities(). > > 3. Why the "unset($var)" in order_update.php? $var already gets reset each > time foreach iterates. So, calling unset() on it at the end of the loop > doesn't really do much. I'm wondering what you were aiming at there. > > Thanks, > > Ben > >
Re: [PHP] session variables - help
> > I have the following code for order_update.php: > > [code] > > session_start(); > extract($_POST); > foreach ($_POST as $var => $val) { > if ($val > 0) { > $_SESSION[$var] = $val; > } else { > unset($var); > > } > header("Location: order_process.php"); > } > > [/code] > > This is not working, however, and it just loads order_process.php with no > values for the varaibles, as if I just refreshed the page with no sessions. Maybe you left it out but I didn't see any place where you used $_SESSION in order_process.php. Also, your redirect in order_update.php appears to be inside your foreach loop, which would definitely mess things right up -- but maybe that was just a typo in your email? Otherwise the logic in order_update.php looks OK, but there are a few side notes that jumped out: 1. I'm not seeing why you used "extract($_POST)" in order_update.php. Right after the extract() call, you iterate through $_POST with a foreach loop, so what's the purpose of calling extract()? Is there more code that you left out? 2. Calling "extract($_POST)" is dangerous. The PHP manual warns against it, although without giving much of an explanation: http://us2.php.net/manual/en/function.extract.php Apart from making it difficult to filter the input you're expecting to see, "extract($_POST)" also allows a malicious end-user to define any variable of his choosing and to overwrite any variables that you may have defined in the script before the extract() call. I like to use filter_input() to read the values of POST variables. By much the same token, you'll want to escape $a, etc., in your writeResultRow() function, with something like htmlentities(). 3. Why the "unset($var)" in order_update.php? $var already gets reset each time foreach iterates. So, calling unset() on it at the end of the loop doesn't really do much. I'm wondering what you were aiming at there. Thanks, Ben
[PHP] session variables - help
I am asking a similar question to one I asked yesterday (which received no answers) with more information in the hopes someone will be kind enough to guide me. I have an order form populated with an array (as opposed to a database table). The user can enter quantities, and the form posts all the information to the order_process page where the values they entered are listed for review. I decided I wanted to allow them to edit quantities before actually submitting the form (by which I mean before using the mail() function). I found that $_SESSION is the way to go. On the order summary page (order_process.php), I start a session and I get all the POST information via: [code] session_start(); extract($_POST); [/code] Instead of echoing the quantity values of each item, I populate an input field with them within an echo: [code] //when this function is called, $a is a the quantity variable $show_01_qty function writeResultRow($a, $b, $c, $d, $e, $f) { if($a != '') { echo ""; . . . } [/code] Now, in order to update a quantity, the user replaces the quantity in the input field with the new number, and clicks a submit button which posts to order_update.php. I have the following code for order_update.php: [code] session_start(); extract($_POST); foreach ($_POST as $var => $val) { if ($val > 0) { $_SESSION[$var] = $val; } else { unset($var); } header("Location: order_process.php"); } [/code] This is not working, however, and it just loads order_process.php with no values for the varaibles, as if I just refreshed the page with no sessions. Help please!
[PHP] SESSION variables: How much is too much?
Hi, I'm trying to learn php mostly by reading the docs and pulling through other peoples projects for reference examples. One particular application I'm looking at has a ton of variables being handled through the SESSION global variable, probably about 25 or so variables. That just seems like alot. Since I'm pretty new to php I was wondering if this was typical and acceptable or if there was another best practice for maintaining large amounts of information throughout a session, like maybe persisting a temporary object in the database and passing a connection...or something. Or is just passing around a pile of variables directly in the SESSION object better? Thanks, Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables
Yeah i guess the cookie doesn't need to be stored on the server since it's in the header anyway. Thanks for clearing that up. Tim-Hinnerk Heuer http://www.ihostnz.com Charles M. Schulz - "I love mankind; it's people I can't stand." 2009/2/7 Stuart > 2009/2/7 Paul M Foster : > > I'm not too clear on HTTP headers, cookies, and such. So here are > > questions related to that. Let's say I generate a random number that I > > want the user to enter in a form. When I generate the number, I store it > > in a session variable ($_SESSION). When the user submits the form, I > > check the number they enter with what I've stored in the session > > variable. > > > > Since this session variable survives across page loads (assuming > > session_start() is appropriately called), how is it stored and recalled? > > > > Is it automatically stored as a cookie on the user's system? > > > > Or is it stored on the server? > > > > And how does a server "get" a cookie? > > > > Is it a separate request made by the server to the client? > > > > If the value I've asked the user for is *not* stored as a cookie, then > > is it passed as part of the HTTP submission or what? > > > > Thanks for any enlightenment on this. > > Session data is stored on the server and tied to a browser using a > cookie. The cookie contains a random string which uniquely identifies > a session on the server. The session_start() function handles all the > details of setting and maintaining that cookie and managing the > server-side data. > > Cookies are transferred between client and server with every request > in the headers. If you don't have Firefox getfirefox.com. The google > for the livehttpheaders addon and install that. Turn it on and browse > your site. You will see the cookies in the headers of both requests > and responses. Cookies are not stored on the server side, they are > sent by the client with each request. > > No additional HTTP requests are involved when using sessions. > > -Stuart > > -- > http://stut.net/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Session variables
2009/2/7 Paul M Foster : > I'm not too clear on HTTP headers, cookies, and such. So here are > questions related to that. Let's say I generate a random number that I > want the user to enter in a form. When I generate the number, I store it > in a session variable ($_SESSION). When the user submits the form, I > check the number they enter with what I've stored in the session > variable. > > Since this session variable survives across page loads (assuming > session_start() is appropriately called), how is it stored and recalled? > > Is it automatically stored as a cookie on the user's system? > > Or is it stored on the server? > > And how does a server "get" a cookie? > > Is it a separate request made by the server to the client? > > If the value I've asked the user for is *not* stored as a cookie, then > is it passed as part of the HTTP submission or what? > > Thanks for any enlightenment on this. Session data is stored on the server and tied to a browser using a cookie. The cookie contains a random string which uniquely identifies a session on the server. The session_start() function handles all the details of setting and maintaining that cookie and managing the server-side data. Cookies are transferred between client and server with every request in the headers. If you don't have Firefox getfirefox.com. The google for the livehttpheaders addon and install that. Turn it on and browse your site. You will see the cookies in the headers of both requests and responses. Cookies are not stored on the server side, they are sent by the client with each request. No additional HTTP requests are involved when using sessions. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables
The session data is stored on the server. In the user's browser, only a session cookie is stored, usually a random session id string. I could never retrieve the session variables with any browser tools, always only with PHP by echoing them out or something. Also, a cookie is simply a text file with a maximum of 4096 characters on the user's browser, not enough to store big session variables with big objects. So, the user's browser just stores a cookie with the session id, so that the server knows which user to map to which session variables. The session variables (in PHP) are stored in the temporary directory on the server in a text file (flattened or serialized), where the server can retrieve them across requests. This is important for security reasons. You might not want the user to be able to view certain variables in their browser otherwise they could change them and cause some damage, e.g. imagine a user has a permission level between 1 and 10 and 1 is the super user. You can store this level in a session variable, and the user cannot change it. If they could, it would be a disaster! Also, if one could store more than 4096 characters, it would be relatively easy to write out some session variables in order to flood the browser memory and make it crash or even worse. Oh, and the Cookies, as far as i know, are always sent in the http headers. They are stored on both client and server and can be set on both sides, with javascript or server side code (php). So they can only be checked in every request by the server side code, and while javascript is being executed on the client. Please correct me if I'm wrong because I would need to review a lot of code in which it is assumed that session variables are NOT stored on the user's machine. Makes sense? Regards, Tim Tim-Hinnerk Heuer http://www.ihostnz.com On Sat, Feb 7, 2009 at 8:11 PM, Phpster wrote: > A Session is stored on the user browser in a session ( in memory cookie) > and on the server as a file. The session mgmt tools will read the file as > needed. > > Bastien > > Sent from my iPod > > > On Feb 7, 2009, at 1:58, Paul M Foster wrote: > > I'm not too clear on HTTP headers, cookies, and such. So here are >> questions related to that. Let's say I generate a random number that I >> want the user to enter in a form. When I generate the number, I store it >> in a session variable ($_SESSION). When the user submits the form, I >> check the number they enter with what I've stored in the session >> variable. >> >> Since this session variable survives across page loads (assuming >> session_start() is appropriately called), how is it stored and recalled? >> >> Is it automatically stored as a cookie on the user's system? >> >> Or is it stored on the server? >> >> And how does a server "get" a cookie? >> >> Is it a separate request made by the server to the client? >> >> If the value I've asked the user for is *not* stored as a cookie, then >> is it passed as part of the HTTP submission or what? >> >> Thanks for any enlightenment on this. >> >> Paul >> -- >> Paul M. Foster >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Session variables
A Session is stored on the user browser in a session ( in memory cookie) and on the server as a file. The session mgmt tools will read the file as needed. Bastien Sent from my iPod On Feb 7, 2009, at 1:58, Paul M Foster wrote: I'm not too clear on HTTP headers, cookies, and such. So here are questions related to that. Let's say I generate a random number that I want the user to enter in a form. When I generate the number, I store it in a session variable ($_SESSION). When the user submits the form, I check the number they enter with what I've stored in the session variable. Since this session variable survives across page loads (assuming session_start() is appropriately called), how is it stored and recalled? Is it automatically stored as a cookie on the user's system? Or is it stored on the server? And how does a server "get" a cookie? Is it a separate request made by the server to the client? If the value I've asked the user for is *not* stored as a cookie, then is it passed as part of the HTTP submission or what? Thanks for any enlightenment on this. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables
I'm not too clear on HTTP headers, cookies, and such. So here are questions related to that. Let's say I generate a random number that I want the user to enter in a form. When I generate the number, I store it in a session variable ($_SESSION). When the user submits the form, I check the number they enter with what I've stored in the session variable. Since this session variable survives across page loads (assuming session_start() is appropriately called), how is it stored and recalled? Is it automatically stored as a cookie on the user's system? Or is it stored on the server? And how does a server "get" a cookie? Is it a separate request made by the server to the client? If the value I've asked the user for is *not* stored as a cookie, then is it passed as part of the HTTP submission or what? Thanks for any enlightenment on this. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION variables
Oops Logins are from http://www.rons-home.net/page/login-greeting/ Blog postings are from http://www.rons-home.net/blog/28/ with the word 'page' gone the session variable doesn't acknowledge the login. Ron On Sat, 2008-10-11 at 21:12 -0400, Ron Piggott wrote: > I did some more testing. The URL is the problem. > > Logins are from > > > On Sat, 2008-10-11 at 19:59 -0400, Daniel Brown wrote: > > On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote: > > > I am programming a blog. > > > > > > index.php sets up the layout for the web page. This includes the > > > heading, left hand and bottom menus. > > > > > > The content is loaded by the command: > > > > > > include($filename); > > > > > > the $_SESSION variables aren't available to files like blog.php . The > > > session variables only work in the initial file, index.php. > > > > Did you remember to add session_start() to the head of the master > > file that's including the other files? > > -- Acts Ministries Christian Evangelism Where People Matter 12 Burton Street Belleville, Ontario, Canada K8P 1E6 [EMAIL PROTECTED] www.actsministrieschristianevangelism.org In Belleville Phone: (613) 967-0032 In North America Call Toll Free: (866) ACTS-MIN Fax: (613) 967-9963 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION variables
I did some more testing. The URL is the problem. Logins are from On Sat, 2008-10-11 at 19:59 -0400, Daniel Brown wrote: > On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote: > > I am programming a blog. > > > > index.php sets up the layout for the web page. This includes the > > heading, left hand and bottom menus. > > > > The content is loaded by the command: > > > > include($filename); > > > > the $_SESSION variables aren't available to files like blog.php . The > > session variables only work in the initial file, index.php. > > Did you remember to add session_start() to the head of the master > file that's including the other files? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION variables
This is one of the first commands given. I am using modrewrites to call the blog entries. blog.php is responsible for displaying both the table of contents and the blog entries. When the table of contents is called (http://www.rons-home.net/page/blog/ ) the session variables are present. When an actual blog entry is displayed ( http://www.rons-home.net/blog/28/ ) the session variables aren't there. I am not sure what is happening / why. The login is at http://www.rons-home.net/page/login/ It has 'page' in the URL. But I am not sure why this should upset the session variables ... Any thoughts? Ron On Sat, 2008-10-11 at 19:59 -0400, Daniel Brown wrote: > On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote: > > I am programming a blog. > > > > index.php sets up the layout for the web page. This includes the > > heading, left hand and bottom menus. > > > > The content is loaded by the command: > > > > include($filename); > > > > the $_SESSION variables aren't available to files like blog.php . The > > session variables only work in the initial file, index.php. > > Did you remember to add session_start() to the head of the master > file that's including the other files? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION variables
On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote: > I am programming a blog. > > index.php sets up the layout for the web page. This includes the > heading, left hand and bottom menus. > > The content is loaded by the command: > > include($filename); > > the $_SESSION variables aren't available to files like blog.php . The > session variables only work in the initial file, index.php. Did you remember to add session_start() to the head of the master file that's including the other files? -- More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SESSION variables
I am programming a blog. index.php sets up the layout for the web page. This includes the heading, left hand and bottom menus. The content is loaded by the command: include($filename); the $_SESSION variables aren't available to files like blog.php . The session variables only work in the initial file, index.php. I am NOT using frames. The web page is loaded all at the same time. Simply when index.php is done, it passes the "baton" to the next .php file to display the specific information the user is requesting. Any ideas / suggestions? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables disappear (some of them only)
Hi ! I have a very weird issue since the last Apache upgrade (-> 2.2.8-r3, a month ago), but I'm not sure it is related (well, I'm pretty sure it's not). Like many people, I've written an application that use PHP session variables, like $_SESSION["my_variable"]. Sometimes (it doesn't happen all the time), _some_ of these variables are not written in the session file and they are lost after a simple header("Location:...); (same domain). The session file is in the right directory (permissions are fine), but some of my variables are missing. The facts : - Apache 2.2.9 + PHP 5.2.6_rc4 running on a Gentoo (up-to-date) - all my scripts begin with session_start(). I've tried to add session_write_close() before every header(Location:...) call, it doesn't help. - I didn't change anything in my program (it has been running just fine for 2 years), it just began to fail from time to time (I would say 10 times a day). There is no hidden unset() function : it would fail for everyone. - these variables are all set correctly, and they don't have reserved names. - only a few variables disappear, but they are always the same ones (could it depend on their position in the session file ?!?) - the session files are very small (max 100ko) - it seems that it doesn't depend on the browser, but IE6 and IE7 seem to be the most affected ones (it may be because my users mostly use these browsers). - I can't reproduce this issue from my local network (any OS/browser - it would be too easy :) - reverting to the previous stable Apache and/or PHP versions doesn't help. - I didn't change any php.ini directive. Any idea ? Thanks ! PS: if you need more details, just ask. The only thing I can't do is pasting the code : the scripts are quite huge. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables on Windows
Does some well-known problem exist with the session variables in Windows servers? Because in a system that I have running on a Windows server, sometimes the session variables are null causing errors, then I close the browser and open it and in the next intent everything works well... I can't understand why... The same system in a Linux server runs well always ¿? Ahead of time, thank you very much, Tom. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session variables and words with spaces
Yep, I see that now. I really need to take a break - been at this way to long. Thanks to all. -Original Message- From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: May 31, 2006 3:02 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] Session variables and words with spaces Beauford wrote: > >Thanks - Done that though. It shows the way it should be. > >Example: Niagara Falls > > > > which of course is wrong and explains perfectly why you are getting the results you are getting... it *should* display: Niagra Falls (View source is a powerful tool!) -Brad >-Original Message- >From: Brad Bonkoski [mailto:[EMAIL PROTECTED] >Sent: May 31, 2006 2:28 PM >To: Beauford >Cc: php-general@lists.php.net >Subject: Re: [PHP] Session variables and words with spaces > >Perhaps you should load up your initial form and then use the "view source" >option in your browser as this will probably give you insight into your >problems... >-Brad > >Beauford wrote: > > > >>Hi, >> >>I have a form in which a drop down field is populated from a MySQL >> >> >database. > > >>I am also using sessions. >> >>The problem is this. After I submit the form the session variable only >>shows the part of the input before the space. >> >>Example: if I choose Niagra Falls from the drop down list, then I only >>see Niagra when I display it. >> >>I'm not sure though if it is the session or the forms variable that is >>causing the problem. I haven't been able to find much on this. >> >>See code below >> >>Thanks >> >> >> >>session_start( ); >> >>..Open database and connect to server... >> >>Include("connect.inc"); >> >>!! Start of form !! >> >> >>-- Select Province -- >> >>> >>$query = "select pid, location from province order by location"; >>$results = >>mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { >> $dberror = "Messed Up"; >> include("index.php"); >> exit; >> } >> >>while ($line = mysql_fetch_array($results)) { >> if($line['pid'] == 1) { >> echo ">Value="$line['location'].">"$line['location']."\n"; >> } >>} >> >> >> >>!! Rest of Form !! >> >> >> >> >> > >-- > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session variables and words with spaces
Not sure why I would get a parse error, but that did correct the problem. I just completely missed the single quote. I never even clue'd in when I looked at the source of the page. Sometimes another pair of eyes does the trick. Maybe it's time for a break. Thanks >> I'm surprised you're not getting a parse error... echo "" . $line['location'] . "\n"; -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables and words with spaces
Niagara Falls replace with Niagara Falls (note the quotes) because you will post only "Niagara" instead "Niagara Falls" cheers, On 5/31/06, Beauford <[EMAIL PROTECTED]> wrote: Thanks - Done that though. It shows the way it should be. Example: Niagara Falls -Original Message- From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: May 31, 2006 2:28 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] Session variables and words with spaces Perhaps you should load up your initial form and then use the "view source" option in your browser as this will probably give you insight into your problems... -Brad Beauford wrote: >Hi, > >I have a form in which a drop down field is populated from a MySQL database. >I am also using sessions. > >The problem is this. After I submit the form the session variable only >shows the part of the input before the space. > >Example: if I choose Niagra Falls from the drop down list, then I only >see Niagra when I display it. > >I'm not sure though if it is the session or the forms variable that is >causing the problem. I haven't been able to find much on this. > >See code below > >Thanks > > > >session_start( ); > >..Open database and connect to server... > >Include("connect.inc"); > >!! Start of form !! > > >-- Select Province -- > > >$query = "select pid, location from province order by location"; >$results = >mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { > $dberror = "Messed Up"; > include("index.php"); > exit; > } > >while ($line = mysql_fetch_array($results)) { > if($line['pid'] == 1) { > echo "Value="$line['location'].">"$line['location']."\n"; > } >} > > > >!! Rest of Form !! > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables and words with spaces
Beauford wrote: Thanks - Done that though. It shows the way it should be. Example: Niagara Falls which of course is wrong and explains perfectly why you are getting the results you are getting... it *should* display: Niagra Falls (View source is a powerful tool!) -Brad -Original Message- From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: May 31, 2006 2:28 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] Session variables and words with spaces Perhaps you should load up your initial form and then use the "view source" option in your browser as this will probably give you insight into your problems... -Brad Beauford wrote: Hi, I have a form in which a drop down field is populated from a MySQL database. I am also using sessions. The problem is this. After I submit the form the session variable only shows the part of the input before the space. Example: if I choose Niagra Falls from the drop down list, then I only see Niagra when I display it. I'm not sure though if it is the session or the forms variable that is causing the problem. I haven't been able to find much on this. See code below Thanks session_start( ); ..Open database and connect to server... Include("connect.inc"); !! Start of form !! -- Select Province -- $query = "select pid, location from province order by location"; $results = mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $dberror = "Messed Up"; include("index.php"); exit; } while ($line = mysql_fetch_array($results)) { if($line['pid'] == 1) { echo ""$line['location']."\n"; } } !! Rest of Form !! -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session variables and words with spaces
Thanks - Done that though. It shows the way it should be. Example: Niagara Falls -Original Message- From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: May 31, 2006 2:28 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] Session variables and words with spaces Perhaps you should load up your initial form and then use the "view source" option in your browser as this will probably give you insight into your problems... -Brad Beauford wrote: >Hi, > >I have a form in which a drop down field is populated from a MySQL database. >I am also using sessions. > >The problem is this. After I submit the form the session variable only >shows the part of the input before the space. > >Example: if I choose Niagra Falls from the drop down list, then I only >see Niagra when I display it. > >I'm not sure though if it is the session or the forms variable that is >causing the problem. I haven't been able to find much on this. > >See code below > >Thanks > > > >session_start( ); > >..Open database and connect to server... > >Include("connect.inc"); > >!! Start of form !! > > >-- Select Province -- > > >$query = "select pid, location from province order by location"; >$results = >mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { > $dberror = "Messed Up"; > include("index.php"); > exit; > } > >while ($line = mysql_fetch_array($results)) { > if($line['pid'] == 1) { > echo "Value="$line['location'].">"$line['location']."\n"; > } >} > > > >!! Rest of Form !! > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables and words with spaces
Beauford wrote: Hi, I have a form in which a drop down field is populated from a MySQL database. I am also using sessions. The problem is this. After I submit the form the session variable only shows the part of the input before the space. Example: if I choose Niagra Falls from the drop down list, then I only see Niagra when I display it. I'm not sure though if it is the session or the forms variable that is causing the problem. I haven't been able to find much on this. See code below Thanks session_start( ); ..Open database and connect to server... Include("connect.inc"); !! Start of form !! -- Select Province -- $query = "select pid, location from province order by location"; $results = mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $dberror = "Messed Up"; include("index.php"); exit; } while ($line = mysql_fetch_array($results)) { if($line['pid'] == 1) { echo ""$line['location']."\n"; } } I'm surprised you're not getting a parse error... echo "" . $line['location'] . "\n"; -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables and words with spaces
Perhaps you should load up your initial form and then use the "view source" option in your browser as this will probably give you insight into your problems... -Brad Beauford wrote: Hi, I have a form in which a drop down field is populated from a MySQL database. I am also using sessions. The problem is this. After I submit the form the session variable only shows the part of the input before the space. Example: if I choose Niagra Falls from the drop down list, then I only see Niagra when I display it. I'm not sure though if it is the session or the forms variable that is causing the problem. I haven't been able to find much on this. See code below Thanks session_start( ); ..Open database and connect to server... Include("connect.inc"); !! Start of form !! -- Select Province -- $query = "select pid, location from province order by location"; $results = mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $dberror = "Messed Up"; include("index.php"); exit; } while ($line = mysql_fetch_array($results)) { if($line['pid'] == 1) { echo ""$line['location']."\n"; } } !! Rest of Form !! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables and words with spaces
Hi, I have a form in which a drop down field is populated from a MySQL database. I am also using sessions. The problem is this. After I submit the form the session variable only shows the part of the input before the space. Example: if I choose Niagra Falls from the drop down list, then I only see Niagra when I display it. I'm not sure though if it is the session or the forms variable that is causing the problem. I haven't been able to find much on this. See code below Thanks session_start( ); ..Open database and connect to server... Include("connect.inc"); !! Start of form !! -- Select Province -- "$line['location']."\n"; } } !! Rest of Form !! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php session variables limited to 1 character -- please help
Zac Smith schrieb: > http://www.triptrivia.com/step2-debug.php?State=abc 404 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php session variables limited to 1 character -- please help
Hi! I've got a very strange issue that is basically cutting off session variable data after 1 character. When I set the session variable as "50" it comes back as "5". When I set it to "XYZ" it comes back as "X". I have a script that is taking $_GET['State'] variable and setting it to a session variable named $USER['State']. This worked fine until a few days ago, but now it's persistent! Any ideas what might be causing this?? I've searched the web/lists and can't find any reference. http://www.triptrivia.com/step2-debug.php?State=abc Thanks, Zac -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables are not stored when set in implicitly called constructor!??
Hallo everybody, hope I am writing to correct mailinglist(^_^*)... I have troubles with sessions and descructor in php5. Can not set session variable in destructor when it's called implicitly. Do You know solution please? I think problem is that session is stored before imlicit object destruction *doh* example.php: doSomeThink(); echo "This should be hallo 2nd time: " . $_SESSION["variable"];// unfortunatly this is not set echo " Click and cry;-("; // implicit desturctor call ?> Thank You very much... BR a3c -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables not unsetting
I'm having a problem with session variables. A site that works fine on my local system (PHP 4.3.4) is not working on the live server (4.1.2). In both cases, register_globals is OFF. Every page starts with session_start() and I'm setting session vars by simply assigning them to $_SESSION, eg: $_SESSION['message'] = "Some message for the next page"; I have a function that is included into every page that goes like this: function show_message() { if(isset($_SESSION['message'])) { echo $_SESSION['message']; unset($_SESSION['message']); } } Calling tha function prints the message okay, but doesn't unset the session var, so once the message is set, it shows on every subsequent page until set to a different message. I even tried using session_unregister($_SESSION['message']) even though the manual says not to. What am I missing here? -- @+ Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
On Monday 06 September 2004 14:08, Peter Brodersen wrote: > On Mon, 6 Sep 2004 13:33:02 +0800, in php.general > > [EMAIL PROTECTED] (Jason Wong) wrote: > >> $username = trim(addslashes($_POST['user_name'])); > >> $pass = trim(addslashes($_POST['password'])); > > > >addslashes() is not needed as you're performing SELECT query and not an > > INSERT query. > > How did you come up with that? The escape mechanism is the same for > SELECT and INSERT. Sorry, you're right. I'll go back to sleep now! -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* A beautiful woman is a blessing from Heaven, but a good cigar is a smoke. -- Kipling */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Dre wrote: no I did this a long time ago (I did have this problem before :o) ) Try echo $_REQUEST[session_name()]; in members/main.php. It should print the session id. Then there should be a session file sess_[session id]. "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Dre wrote: and by the way .. I'm using MS Windows XP Pro. which I do believe that it has some hand in the problem :) Like you did not change session.save_path setting in php.ini from /tmp to whatever it is supposed to be on windows. "Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I do know this and what happen is that the $_SESSION array become empty once I redirect from the login page (after login) to another members' area page .. !! "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Dre wrote: I don't know why but session variables does not get posted .. is there any thing in the php.ini that I should configure as I can't find any thing wrong in the code I'm using !! Session variables are not posted, they are kept on the server. Only the session id is sent as a cookie, get or post variable. Session variables are available in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
no I did this a long time ago (I did have this problem before :o) ) "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dre wrote: > > and by the way .. > > I'm using MS Windows XP Pro. which I do believe that it has some hand in the > > problem :) > > Like you did not change session.save_path setting in php.ini from /tmp > to whatever it is supposed to be on windows. > > > > > > > "Dre" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>I do know this > >>and what happen is that the $_SESSION array become empty once I redirect > >>from the login page (after login) to another members' area page .. !! > >> > >> > >>"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message > >>news:[EMAIL PROTECTED] > >> > >>>Dre wrote: > >>> > I don't know why but session variables does not get posted .. is there > >> > >>any > >> > thing in the php.ini that I should configure as > I can't find any thing wrong in the code I'm using !! > > >>> > >>>Session variables are not posted, they are kept on the server. Only the > >>>session id is sent as a cookie, get or post variable. Session variables > >>>are available in $_SESSION array > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
--- Jason Wong <[EMAIL PROTECTED]> wrote: > > $username = trim(addslashes($_POST['user_name'])); > > $pass = trim(addslashes($_POST['password'])); > > addslashes() is not needed as you're performing SELECT query > and not an INSERT query. That's not true, since he's using user data in the SQL statement. The query method has nothing to do with whether data should be escaped. Of course, addslashes() is sort of a last result with regard to escaping data for use in a query. The more preferable options are those native to the database you're using, if they exist. MySQL users can use mysql_escape_string(), for example. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Dre wrote: and by the way .. I'm using MS Windows XP Pro. which I do believe that it has some hand in the problem :) Like you did not change session.save_path setting in php.ini from /tmp to whatever it is supposed to be on windows. "Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I do know this and what happen is that the $_SESSION array become empty once I redirect from the login page (after login) to another members' area page .. !! "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Dre wrote: I don't know why but session variables does not get posted .. is there any thing in the php.ini that I should configure as I can't find any thing wrong in the code I'm using !! Session variables are not posted, they are kept on the server. Only the session id is sent as a cookie, get or post variable. Session variables are available in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
On Mon, 6 Sep 2004 13:33:02 +0800, in php.general [EMAIL PROTECTED] (Jason Wong) wrote: >> $username = trim(addslashes($_POST['user_name'])); >> $pass = trim(addslashes($_POST['password'])); > >addslashes() is not needed as you're performing SELECT query and not an INSERT >query. How did you come up with that? The escape mechanism is the same for SELECT and INSERT. addslashes() is not needed if magic_quotes is enabled, though. But if it isn't, it could be easy to login as another user, e.g. post: other_user' OR user_name = 'foo .. as user_name. In that case the attacker could login as other_user. -- - Peter Brodersen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Please do not top post. On Monday 06 September 2004 06:53, Dre wrote: As well as what everybody else has said ... > $username = trim(addslashes($_POST['user_name'])); > $pass = trim(addslashes($_POST['password'])); addslashes() is not needed as you're performing SELECT query and not an INSERT query. >$sql = "SELECT * FROM members_webdata WHERE user_name='".$username."' > AND password='".$pass."'"; $sql = "SELECT * FROM members_webdata WHERE user_name='$username' AND password='$pass'"; Much easier on the eyes. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Of course you have a purpose -- to find a purpose. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Dre wrote: yes I'm sure Won't hurt to echo it out. -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
yes I'm sure "John Nichel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dre wrote: > > > if((empty($_POST['user_name'])) || (empty($_POST['password']))) > > { > > header('Location: index.php'); > >include("login_form"); > >exit(); > > } > > That include is useless, as you're forwarding to another document right > before it. > > > else{ > >include("db.php"); > >$sql = "SELECT * FROM members_webdata WHERE user_name='".$username."' > > AND password='".$pass."'"; > >$result = mysql_query($sql); > >$num_return = mysql_num_rows($result); > > > >if($num_return ==1) > >{ > > $row = mysql_fetch_array($result); > > $_SESSION['uname'] = $row['user_name']; > > Are you sure $row['user_name'] has value? > > -- > By-Tor.com > It's all about the Rush > http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Dre wrote: if((empty($_POST['user_name'])) || (empty($_POST['password']))) { header('Location: index.php'); include("login_form"); exit(); } That include is useless, as you're forwarding to another document right before it. else{ include("db.php"); $sql = "SELECT * FROM members_webdata WHERE user_name='".$username."' AND password='".$pass."'"; $result = mysql_query($sql); $num_return = mysql_num_rows($result); if($num_return ==1) { $row = mysql_fetch_array($result); $_SESSION['uname'] = $row['user_name']; Are you sure $row['user_name'] has value? -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
and by the way .. I'm using MS Windows XP Pro. which I do believe that it has some hand in the problem :) "Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I do know this > and what happen is that the $_SESSION array become empty once I redirect > from the login page (after login) to another members' area page .. !! > > > "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Dre wrote: > > > I don't know why but session variables does not get posted .. is there > any > > > thing in the php.ini that I should configure as > > > I can't find any thing wrong in the code I'm using !! > > > > > > > Session variables are not posted, they are kept on the server. Only the > > session id is sent as a cookie, get or post variable. Session variables > > are available in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
this is the username/password validation script which receives the user name and password from a regular form and they are sent correctly logme_in.php //== == "."CLICK HERE TO GO TO MEMBERS SECTION"; echo ""; //session_write_close(); // header('Location: members/main.php'."?_SESSION['uname']=". $row['user_name']); } else { } } ?> // this is the page I try to open after logging in but it behaves like if I'm not logged at all members/main.php // ... // // "Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I do know this > and what happen is that the $_SESSION array become empty once I redirect > from the login page (after login) to another members' area page .. !! > > > "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Dre wrote: > > > I don't know why but session variables does not get posted .. is there > any > > > thing in the php.ini that I should configure as > > > I can't find any thing wrong in the code I'm using !! > > > > > > > Session variables are not posted, they are kept on the server. Only the > > session id is sent as a cookie, get or post variable. Session variables > > are available in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Dre wrote: I do know this and what happen is that the $_SESSION array become empty once I redirect from the login page (after login) to another members' area page .. !! Are you starting the session on every page? How are you sending the session id? -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Dre wrote: I do know this and what happen is that the $_SESSION array become empty once I redirect from the login page (after login) to another members' area page .. !! That means you are loosing your session. Is the session id sent? Is the session file (usualy in /tmp) created? "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Dre wrote: I don't know why but session variables does not get posted .. is there any thing in the php.ini that I should configure as I can't find any thing wrong in the code I'm using !! Session variables are not posted, they are kept on the server. Only the session id is sent as a cookie, get or post variable. Session variables are available in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
I do know this and what happen is that the $_SESSION array become empty once I redirect from the login page (after login) to another members' area page .. !! "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dre wrote: > > I don't know why but session variables does not get posted .. is there any > > thing in the php.ini that I should configure as > > I can't find any thing wrong in the code I'm using !! > > > > Session variables are not posted, they are kept on the server. Only the > session id is sent as a cookie, get or post variable. Session variables > are available in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables does not get sent
Dre wrote: I don't know why but session variables does not get posted .. is there any thing in the php.ini that I should configure as I can't find any thing wrong in the code I'm using !! Session variables are not posted, they are kept on the server. Only the session id is sent as a cookie, get or post variable. Session variables are available in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables does not get sent
I don't know why but session variables does not get posted .. is there any thing in the php.ini that I should configure as I can't find any thing wrong in the code I'm using !! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variables ~ Best Practices
thanks Jay. -- - Michael Mason Arras People www.arraspeople.co.uk - "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] I am also wondering if I need to declare all my variables one after the other or can I simply declare variables that I will be using immediately upon submission. [/snip] Since PHP is not strongly typed (like C or C++) you need not declare any variables. There are some caveats (see http://www.php.net/error_reporting ). Is it good practice? Not really, especially if you have a shop where more than one developer may be touching the code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variables ~ Best Practices
On Tue, 13 Jul 2004 17:52:44 +0100, Harlequin <[EMAIL PROTECTED]> wrote: > I'm right in the middle of developing some pages that will require session > cookies. Now I have a few questions and hope I don't bore you too much... > > I presume I am right in assuming that I can declare variables anywhere I > like providing I have started a session on the page but I cannot actually > use those variables until a post or some similar action has been performed > by the user. > > I am also wondering if I need to declare all my variables one after the > other or can I simply declare variables that I will be using immediately > upon submission. > I'm not quite sure what your question is, but here's some info. You have to call session_start() before using anything in the session. This must be called before there is any output to the browser. After the call to session_start() you can get/set/unset any session value you want at any time in the script (all of this is stored on the server). The best way to do all of this is through the $_SESSION superglobal. Use it like a normal assicative array: $_SESSION['var'] = 'value'; or: $_SESSION['array'] = array(1, 2, 3, 4); os: $_SESSION['object'] = new Object(); Everything you put in there will be available from any function without having to use the global keyword or the $GLOBALS superglobal. Note that you can't store recources in the session (at least, they can't be used as resources on subsequent requests.) This includes things such as open file desriptors and database connections or statement handles. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Variables ~ Best Practices
> I presume I am right in assuming that I can declare variables anywhere I > like providing I have started a session on the page but I cannot > actually use those variables until a post or some similar action has > been performed by the user. No, you can use them right away - they are stored server-side, so you don't need to wait for a request/response loop before reading them: session_start(); $_SESSION['foo'] = 'bar'; echo $_SESSION['foo']; // 'foo' is available immediately No need to perform any special declarations. It's cookies that need to wait for a subsequent request to be available via getcookie(). Careful with your session variable naming - you may want to implement a primitive namespace, by using named arrays in $_SESSION, such as $_SESSION['auth']['username'] or $_SESSION['prefs']['boxers_or_briefs']. -mike. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Variables ~ Best Practices
[snip] I am also wondering if I need to declare all my variables one after the other or can I simply declare variables that I will be using immediately upon submission. [/snip] Since PHP is not strongly typed (like C or C++) you need not declare any variables. There are some caveats (see http://www.php.net/error_reporting ). Is it good practice? Not really, especially if you have a shop where more than one developer may be touching the code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Variables ~ Best Practices
I'm right in the middle of developing some pages that will require session cookies. Now I have a few questions and hope I don't bore you too much... I presume I am right in assuming that I can declare variables anywhere I like providing I have started a session on the page but I cannot actually use those variables until a post or some similar action has been performed by the user. I am also wondering if I need to declare all my variables one after the other or can I simply declare variables that I will be using immediately upon submission. -- - Michael Mason Arras People www.arraspeople.co.uk - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables
On 06/01/04 22:12 John Nichel spoke: Bob Lockie wrote: $_SESSION['new_name'] = $_REQUEST['new_name']; Is not global. I printed out the value locally but it is not made into a session variable. Did you start the session before you set $_SESSION['new_name']? That was my problem. I reorganized and put some code in a file that didn't have a session_start() call. :-( Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php