[PHP] PLEASE HELP! session variable fails to persist!!
Hi, My session variables won't persist, could someone help me with this problem? I spent all day trying to figure out what is wrong, and I still don't know why I couldn't get it to work. Here is an example script: "; echo "session var: ".$_SESSION["var"].""; fnB(); function fnA(){ $_SESSION["var"]=1; } function fnB(){ if(isset($_SESSION["var"])){ echo "session var is set..."; } else{ echo "session var is not set..."; fnA(); echo $_SESSION["var"]; } } ?> Here is the out put from this script: " session id: ee030ac6e15ea2c01e1dd4fe40f3ab30 session var: session var is not set... 1 " The session ID is the same for a given session, that means the server knows its the same session. And since I get the value "1" each time, I can see that the $_SESSION["var"] is a global variable with a value of "1". But it seems that once the script is finished, this variable runs out of scope! A session variable should persist for the duration of the session. It should not run out of scope like this. Could someone with more experience tell me what am I doing wrong? Thanks in advance. Zlutarch _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PLEASE HELP! session variable fails to persist!!
Hi Stuart, I tried your idea but it didn't work. When I used session_encode(), I got nothing! It seems that it's not being registered as a session variable. Any idea why that is the case? Thanks, Zlutarch >From: Stuart Dallas <[EMAIL PROTECTED]> >Reply-To: Stuart Dallas <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Re: [PHP] PLEASE HELP! session variable fails to persist!! >Date: Sat, 15 Jun 2002 01:05:47 +0100 > >On Saturday, June 15, 2002 at 12:53:47 AM, Zlutarch G. wrote: > > The session ID is the same for a given session, that means the server >knows > > its the same session. And since I get the value "1" each time, I can see > > that the $_SESSION["var"] is a global variable with a value of "1". But >it > > seems that once the script is finished, this variable runs out of scope! >A > > session variable should persist for the duration of the session. It >should > > not run out of scope like this. Could someone with more experience tell >me > > what am I doing wrong? Thanks in advance. > >Your code looks ok so I'm guessing that you are just refreshing this page >to >see if the session variables persist. If that is the case then of course >you're >not seeing them persist. In order for the page to import the current >session it >must know what the session id is. Try putting a link on that page that >links to >the same page. Click on the link and you should find that the session >variable >now persists. > >-- >Stuart > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] PLEASE HELP! session variable fails to persist!!
Hi Stuart, I tried your script, but I couldn't get it to work. I guess it has to be something wrong with my server configuration? I am using Apache 1.3.14. I am new to Apache, so I don't know what could possibly be the configuration problem. Do you have any ideas? Thanks a lot. Zlutarch >From: Stuart Dallas <[EMAIL PROTECTED]> >Reply-To: Stuart Dallas <[EMAIL PROTECTED]> >To: "Zlutarch G." <[EMAIL PROTECTED]> >Subject: Re[2]: [PHP] PLEASE HELP! session variable fails to persist!! >Date: Sat, 15 Jun 2002 01:32:51 +0100 > >On Saturday, June 15, 2002 at 1:24:43 AM, you wrote: > > I tried including a link, but it didn't work. When I used >session_encode(), > > I got nothing! Some how it was not registered as a session variable. Any > > idea why that could be? > >I hope this will help clear up any confusion. > >Go here: http://www.devserver.org/test/session.php and click on the link. > >This is the code... > > session_start(); > $sID=session_id(); > echo "session id: $sID"; > echo "session var: ".$_SESSION["var"].""; > > fnB(); > function fnA(){ > $_SESSION["var"]=1; > } > function fnB(){ > if(isset($_SESSION["var"])){ > echo "session var is set..."; > } > else{ > echo "session var is not set..."; > fnA(); > echo $_SESSION["var"]; > } > } > > print 'reload page'; >?> > >It works. If this code doesn't work for you then it's something wrong with >your >server configuration. > >-- >Stuart > _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[4]: [PHP] PLEASE HELP! session variable fails to persist!!
Hi Stuart, Thanks. I added error_reporting (E_ALL); and it gave me the following error msg: "Warning: Undefined index: var in c:\program files\apache group\apache\htdocs\php\superstock\ssi\valuecalc\valuescreen\testsess.php on line 6" Here is line 6: echo "session var: ".$_SESSION["var"].""; Apparently, there is no session variable! Does that mean the session was not created? I thought the session is created if I get the same session ID each time I reload the page. Zlutarch P.S. I wish I could post the server address, but its on a private network. Only computers on the intra net have access to the server. I will see what I can do. >From: Stuart Dallas <[EMAIL PROTECTED]> >Reply-To: Stuart Dallas <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Re[4]: [PHP] PLEASE HELP! session variable fails to persist!! >Date: Sat, 15 Jun 2002 01:49:40 +0100 > >On Saturday, June 15, 2002 at 1:42:45 AM, Zlutarch G. wrote: > > I tried your script, but I couldn't get it to work. I guess it has to be > > something wrong with my server configuration? I am using Apache 1.3.14. >I am > > new to Apache, so I don't know what could possibly be the configuration > > problem. Do you have any ideas? Thanks a lot. > >Do you get any errors? Add the following line immediately before the call >to >session_start()... > >error_reporting (E_ALL); > >My guess is that it's failing to create the session, but if your error >reporting is too low you may not be told about it. > >Is the server you are using public? Can you post the URL so we can take a >look? > >-- >Stuart > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How can I open URL using HTTP POST instead of HTTP GET?
Hi everyone, PHP fopen function opens URL using the HTTP GET method. But what if one could only open the web page using the HTTP POST method? In this case, fopen won't work. Is there a PHP function that is similar to fopen, but uses HTTP POST method to open URL instead? If not, then how do I work around this problem? Thanks, Zlu _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Apache.exe fails Java
Hi, I am learning how to use the PHP Java extension. I used the example script/codes found in the PHP Java documentation:" getProperty('java.version').' '; print 'Java vendor=' .$system->getProperty('java.vendor').' '; print 'OS='.$system->getProperty('os.name').' '. $system->getProperty('os.version').' on '. $system->getProperty('os.arch').' '; // java.util.Date example $formatter = new Java('java.text.SimpleDateFormat', ", dd, 'at' h:mm:ss a "); print $formatter->format(new Java('java.util.Date')); ?>" And I got the correct output: Java version=1.3.0 Java vendor=Sun Microsystems Inc. OS=Windows 2000 5.0 on x86 Sunday, February 17, 2002 at 3:28:42 AM Greenwich Mean Time However, the script also crashed Apache.exe each time it was run. It gave me the following error message: "Apache.exe has generated errors and will be closed by Windows. You will need to restart the program." Does anyone know what is going on? Why Apache.exe kept crashing after runing this PHP script? Thanks, Zlutarch _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HELP! Open "HTTPS://", and follow rediect header
Hi All, I need help on two problems: 1) Is there a PHP function similar to fopen() that would open URL begins with "https://";, i.e., SSL address? 2) Does anyone know if it is possible in PHP to read redirect instructions in HTTP header, and then follow the links? Thanks in advance, Zlu _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is there a setInterval function in PHP?
Hi, I couldn't find a similar function in the official documentation. Does anyone know if there is a setInterval function in PHP? i.e., making repeated calls to a function separated by a given time period. Is such a function even possible in PHP? One way to do it, without a PHP function, is to use a HTML meta tag, but then the whole script would be called, not just a specific function. That's what I have been using, but it's a poor man's way of doing things, not very elegant. I thought a function such as setInterval would be the way to go, and it would be an esay way to stream data. Zlutarch _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]