From: 李辰 <lic...@ho...> - 2012-08-20 04:41:53
|
Hi, all, I am new to Squirrel mail and not sure if this is the right place to ask questions. In a research project, I need for some reason to modify the sm code. Specifically, I need to modify the right_main.php, so that each time when I click "inbox" it will not call sqimap_login() again if we already have one imap session remaining. I do not logout from imap explicitly. Only the first time we need to create a imap connection. My problem is, with the below code(the output followed), I cannot get back the imapConnection when I click inbox or simply refresh the page. Any suggestions? Thanks very much. /* Open a connection on the imap port (143) */global $imapConnection;//var_dump("$username");//var_dump("$imapConnection");sqgetGlobalVar('imap',$imapConnection,SQ_SESSION);echo "Before: "; var_dump("$imapConnection");echo "<br />";//echo "Before: $imapConnection <br />"; if(empty($imapConnection)) { $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); sqsession_register($imapConnection,'imap'); sqgetGlobalVar('imap',$imap,SQ_SESSION);//check if I've put imap connection descriptor to SESSION successfully. var_dump("$imap"); }echo "After:"; var_dump("$imapConnection"); The output is : Before: string(1) "0" string(15) "Resource id #65" After:string(15) "Resource id #65" Regards,Jerry |
From: Tomas K. <to...@us...> - 2012-08-20 16:40:56
|
李辰-2 wrote: > > > Hi, all, > I am new to Squirrel mail and not sure if this is the right place to ask > questions. In a research project, I need for some reason to modify the sm > code. Specifically, I need to modify the right_main.php, so that each time > when I click "inbox" it will not call sqimap_login() again if we already > have one imap session remaining. I do not logout from imap explicitly. > Only the first time we need to create a imap connection. My problem is, > with the below code(the output followed), I cannot get back the > imapConnection when I click inbox or simply refresh the page. > > Any suggestions? Thanks very much. Connections are not persistent in PHP scripts and IMHO you can't store socket objects in session. Every time you call a script, you are creating new environment for it. See information about IMAP proxy. (http://www.squirrelmail.org/docs/admin/admin-6.html#ss6.6) -- Tomas -- View this message in context: http://old.nabble.com/small-problem-about-retrieving-variable-from-SESSION%E2%80%8F-tp34322640p34325379.html Sent from the squirrelmail-devel mailing list archive at Nabble.com. |
From: lichen970 <lic...@ho...> - 2012-08-21 00:52:41
|
Thanks for relying me. And here's something I may need to clarify. I am not creating a new PHP session I think. The session IDs are the same. I just want to only maintain one IMAP connection within a sqmail session. I am not trying to store the sq session itself. Tomas Kuliavas wrote: > > > 李辰-2 wrote: >> >> >> Hi, all, >> I am new to Squirrel mail and not sure if this is the right place to ask >> questions. In a research project, I need for some reason to modify the sm >> code. Specifically, I need to modify the right_main.php, so that each >> time when I click "inbox" it will not call sqimap_login() again if we >> already have one imap session remaining. I do not logout from imap >> explicitly. Only the first time we need to create a imap connection. My >> problem is, with the below code(the output followed), I cannot get back >> the imapConnection when I click inbox or simply refresh the page. >> >> Any suggestions? Thanks very much. > > Connections are not persistent in PHP scripts and IMHO you can't store > socket objects in session. Every time you call a script, you are creating > new environment for it. > > See information about IMAP proxy. > (http://www.squirrelmail.org/docs/admin/admin-6.html#ss6.6) > > -- > Tomas > -- View this message in context: http://old.nabble.com/small-problem-about-retrieving-variable-from-SESSION%E2%80%8F-tp34322640p34327143.html Sent from the squirrelmail-devel mailing list archive at Nabble.com. |
From: lichen970 <lic...@ho...> - 2012-08-21 00:55:05
|
Maybe there's some format issue in my first post. So just repost it as below. Hi, all, I am new to Squirrel mail and not sure if this is the right place to ask questions. In a research project, I need for some reason to modify the sm code. Specifically, I need to modify the right_main.php, so that each time when I click "inbox" it will not call sqimap_login() again if we already have one imap session remaining. I do not logout from imap explicitly. Only the first time we need to create a imap connection. My problem is, with the below code(the output followed), I cannot get back the imapConnection when I click inbox or simply refresh the page. Any suggestions? Thanks very much. /* Open a connection on the imap port (143) */ global $imapConnection; //var_dump("$username"); //var_dump("$imapConnection"); sqgetGlobalVar('imap',$imapConnection,SQ_SESSION); echo "Before: "; var_dump("$imapConnection");echo "<br />"; //echo "Before: $imapConnection <br />"; if(empty($imapConnection)) { $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); sqsession_register($imapConnection,'imap'); sqgetGlobalVar('imap',$imap,SQ_SESSION);//check if I've put imap connection descriptor to SESSION successfully. var_dump("$imap"); } echo "After:"; var_dump("$imapConnection"); The output is : Before: string(1) "0" string(15) "Resource id #65" After:string(15) "Resource id #65" Thanks -- View this message in context: http://old.nabble.com/small-problem-about-retrieving-variable-from-SESSION%E2%80%8F-tp34322640p34327147.html Sent from the squirrelmail-devel mailing list archive at Nabble.com. |
From: Paul L. <pa...@sq...> - 2012-08-21 02:26:06
|
On Mon, Aug 20, 2012 at 5:52 PM, lichen970 <lic...@ho...> wrote: > > Thanks for relying me. And here's something I may need to clarify. I am not > creating a new PHP session I think. The session IDs are the same. I just > want to only maintain one IMAP connection within a sqmail session. I am not > trying to store the sq session itself. What you're trying to do is not possible in PHP. All connections are shut down when the request is finished processing. It's the same reason PHP doesn't support database connection pooling, etc. This is exactly why IMAP Proxy exists. -- Paul Lesniewski SquirrelMail Team Please support Open Source Software by donating to SquirrelMail! http://squirrelmail.org/donate_paul_lesniewski.php |
From: lichen970 <lic...@ho...> - 2012-08-21 03:48:56
|
Paul Lesniewski wrote: > > > > What you're trying to do is not possible in PHP. All connections are > shut down when the request is finished processing. It's the same > reason PHP doesn't support database connection pooling, etc. This is > exactly why IMAP Proxy exists. > > -- > Paul Lesniewski > > > yes, u are right sir. Thank you for remind me this. A follow-up question: could I achieve what I want by replacing fsockopen() with pfsockopen() in the sqimap_login() fucntion, where the imap connection is first created? -- View this message in context: http://old.nabble.com/small-problem-about-retrieving-variable-from-SESSION%E2%80%8F-tp34322640p34327438.html Sent from the squirrelmail-devel mailing list archive at Nabble.com. |
From: Tomas K. <to...@us...> - 2012-08-21 05:13:09
|
lichen970 wrote: > > Thanks for relying me. And here's something I may need to clarify. I am > not creating a new PHP session I think. The session IDs are the same. I > just want to only maintain one IMAP connection within a sqmail session. I > am not trying to store the sq session itself. > If you want to maintain same connection on different PHP script calls, you need to transfer connection information. Information is transfered by using session data storage. SquirrelMail keeps IMAP connection resource in $imapConnection variable. If you want to preserve $imapConnection variable for use in other page call, you have to store it in session. This variable is stream object and you can't store stream objects in session. PHP webmails don't use persistent IMAP connections. Please use IMAP proxy, if you want to maintain persistent IMAP connections in PHP based IMAP clients. -- Tomas -- View this message in context: http://old.nabble.com/small-problem-about-retrieving-variable-from-SESSION%E2%80%8F-tp34322640p34327556.html Sent from the squirrelmail-devel mailing list archive at Nabble.com. |
From: lichen970 <lic...@ho...> - 2012-08-22 01:50:46
|
Tomas Kuliavas wrote: > > If you want to maintain same connection on different PHP script calls, you > need to transfer connection information. Information is transfered by > using session data storage. SquirrelMail keeps IMAP connection resource in > $imapConnection variable. If you want to preserve $imapConnection variable > for use in other page call, you have to store it in session. This variable > is stream object and you can't store stream objects in session. PHP > webmails don't use persistent IMAP connections. > > Please use IMAP proxy, if you want to maintain persistent IMAP connections > in PHP based IMAP clients. > Thanks for your suggestion. I am now at a better place to understand it. I may have to use IMAP proxy at that sense. -- View this message in context: http://old.nabble.com/small-problem-about-retrieving-variable-from-SESSION%E2%80%8F-tp34322640p34332433.html Sent from the squirrelmail-devel mailing list archive at Nabble.com. |