[PHP-DB] Problem using session bu submitting the session id through a form
Hi, My session only seems to work when I use the link-tag (like a href=nextpage.php?PHPSESSIONID=blahblahblah/a But when I send the sessionid within a form in a hidden tag (input type=hidden name=phpsessionid value=blahblah) the session stops. For my session working correct i have to send my sessionid at every link and at every submit. My question now is, how can i send the sessionid by using a form and not by putting the sessionid in the a-tag? Greetz Henk Jan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem using session bu submitting the session id through a form
Hi, Not certain what is happening try the following script. On my machine the form retains the session ID. Note the sending the ID as a GET is only done for cross checking. You can remove it and there will be no change in the display. ?php session_start(); ? html body ?php $id = session_id(); echo $id ? form action=test1.php??php echo $id? method=post input type=submit/form /body /html If you run this and don't get the session ID being maintained then there would appear to be some problem with your set up but we'll probably require more info OS php version etc. graeme. Henk Jan Wils wrote: Hi, My session only seems to work when I use the link-tag (like a href=nextpage.php?PHPSESSIONID=blahblahblah/a But when I send the sessionid within a form in a hidden tag (input type=hidden name=phpsessionid value=blahblah) the session stops. For my session working correct i have to send my sessionid at every link and at every submit. My question now is, how can i send the sessionid by using a form and not by putting the sessionid in the a-tag? Greetz Henk Jan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem using session bu submitting the session id througha form
thanx, i did use the GET method to send a form. with the POST i works!!! thanks again! - Original Message - From: graeme [EMAIL PROTECTED] To: Henk Jan Wils [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Saturday, January 08, 2005 11:36 AM Subject: Re: [PHP-DB] Problem using session bu submitting the session id througha form Hi, Not certain what is happening try the following script. On my machine the form retains the session ID. Note the sending the ID as a GET is only done for cross checking. You can remove it and there will be no change in the display. ?php session_start(); ? html body ?php $id = session_id(); echo $id ? form action=test1.php??php echo $id? method=post input type=submit/form /body /html If you run this and don't get the session ID being maintained then there would appear to be some problem with your set up but we'll probably require more info OS php version etc. graeme. Henk Jan Wils wrote: Hi, My session only seems to work when I use the link-tag (like a href=nextpage.php?PHPSESSIONID=blahblahblah/a But when I send the sessionid within a form in a hidden tag (input type=hidden name=phpsessionid value=blahblah) the session stops. For my session working correct i have to send my sessionid at every link and at every submit. My question now is, how can i send the sessionid by using a form and not by putting the sessionid in the a-tag? Greetz Henk Jan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Problem with session
Hello everyone, I was wondering if anyone can help me with solvoing this problem. For some reason, the session_is_registered() function does not seem to see the session when the page is reloaded. The pages following through all work, except if the user comes back to the index page. At that point the session_ID is incremented. If at the index page, the reload button is continuously pressed, even-though the browser has not been closed, session_is_registered() function fails to find the session and starts a whole new session. I would sincerely appreciate it if anyone may be able to help me out with this. Thanks, -AM p.s. The code I'm talking about is below: ? session_start(); $user_ip= getenv('REMOTE_ADDR'); $user_host = getenv('REMOTE_HOST'); $user_agent = getenv('HTTP_USER_AGENT'); if (!session_is_registered(session_id)) { $db_conn = mysql_pconnect(pals.wright.edu, pals_user, bytes); if (!$db_conn) { $message = $message . Error: Could not connect to database pals.brbr; } mysql_select_db(pals); $query = INSERT INTO session (begdateTime, ip_address, platform) VALUES (now(), '.$user_ip.', '.$user_agent.'); $result = mysql_query($query); $session_id = mysql_insert_id(); if ($result) { $status = session_register(session_id); $isit = session_is_registered(session_id); $message = $message . brbrYour session ID is: $session_idbrbr; } else { $message = $message . Error: Failed to register session id into database.brbr; } } else { $message = $message . You already have a session id: $session_idbrbr; } ?
[PHP-DB] Problem with session function: URL Parameter
I would use the session functions with URL parameter but PHP can't transmit the SID to the link-URL. This methods work: 1. ?php session_id(); session_name(); session_register(username); session_write_close(); ? a href=admin/admin.phtml??=SID?next/a Result: http://admin/admin.phtml?PHPSESSID=85e6077fd4ff6bdd738707335f283ef5 2. ?php session_id(); session_name(); session_register(username); session_write_close(); ? script language=JavaScript function Test() { window.location.href=admin/admin.phtml??=SID?; } /script Result: http://admin/admin.phtml?PHPSESSID=85e6077fd4ff6bdd738707335f283ef5 And this doesn't work: ?php session_id(); session_name(); session_register(username); session_write_close(); echo(script language=\JavaScript\window.location.href=\admin/admin.phtml??php=SID? \;/script); ? Result: http://admin/admin.phtml??=SID? PHP doesn't display the correct SID. Instead the string ?=SID? were displayed! Thank you!!! bye -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Problem with session function: URL Parameter
-Original Message- From: Robert Gruber [mailto:[EMAIL PROTECTED]] Sent: 26 September 2001 22:19 To: [EMAIL PROTECTED] Subject: [PHP-DB] Problem with session function: URL Parameter I would use the session functions with URL parameter but PHP can't transmit the SID to the link-URL. And this doesn't work: ?php session_id(); session_name(); session_register(username); session_write_close(); echo(script language=\JavaScript\window.location.href=\admin/admin.phtml?? php=SID? \;/script); ? Result: http://admin/admin.phtml??=SID? PHP doesn't display the correct SID. Instead the string ?=SID? were displayed! Thank you!!! bye That's because you're using ? ? when you're already inside a php block. Try: admin/admin.phtml?php=SID instead. hth -- Jason Wong Gremlins Associates www.gremlins.com.hk Tel: +852-2573-5033 Fax: +852-2573-5851 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Problem with session function: URL Parameter
Jason Wong [EMAIL PROTECTED] schrieb im Newsbeitrag 001401c1469c$7c788440$[EMAIL PROTECTED]">news:001401c1469c$7c788440$[EMAIL PROTECTED]... -Original Message- From: Robert Gruber [mailto:[EMAIL PROTECTED]] Sent: 26 September 2001 22:19 To: [EMAIL PROTECTED] Subject: [PHP-DB] Problem with session function: URL Parameter I would use the session functions with URL parameter but PHP can't transmit the SID to the link-URL. And this doesn't work: ?php session_id(); session_name(); session_register(username); session_write_close(); echo(script language=\JavaScript\window.location.href=\admin/admin.phtml?? php=SID? \;/script); ? Result: http://admin/admin.phtml??=SID? PHP doesn't display the correct SID. Instead the string ?=SID? were displayed! Thank you!!! bye That's because you're using ? ? when you're already inside a php block. Try: admin/admin.phtml?php=SID instead. Thank you for your answer but it doesn't work If have tried: php=SID =SID ?=SID? ?php=SID? lt?=SID?gt lt?php=SID?gt hth -- Jason Wong Gremlins Associates www.gremlins.com.hk Tel: +852-2573-5033 Fax: +852-2573-5851 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Problem with session vars !
It not related to database. Anyway, If you use $HTTP_SESSION_VARS, forget about session_(un)register(). (Do not use them) Just use $HTTP_SESSION_VARS. It's known issue. (If you use global vars, only use global vars and use session_(un)register()) Regards, -- Yasuo Ohgaki Nicolas Guilhot [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am having problem with PHP4 session variables. I think I misunderstood how they work, and I can't see what I'm doing wrong. Any help would be appreciated. I am using the version from EasyPhp 1.1.1. Below is a short example to explain my problem. I've got two php scripts. 'test1.php' which start a session, set a variable $sess and register it as a session variable. It then redirects to 'test2.php' which only displays session variables and switches $sess[var1] between true and false on each call. With the code in example, I retrieve the variable set by 'test1.php' on 'test2.php', but $HTTP_SESSION_VARS['sess']['var1'] is always true. With the same code, If I set register_globals to off in my php.ini, I get the opposite. I never retrieve the variable set by 'test1.php' on 'test2.php', but $HTTP_SESSION_VARS['sess']['var1'] is switches correctly. What is wrong in this code ?? If I replace session_register('sess'); in 'test1.php' by $GLOBALS['HTTP_SESSION_VARS']['sess'] = $sess; and set register_globals to off everything works. Someone could explain to me why ?? Best regards, Nicolas File test1.php ? function initSessionVar() { global $sess; // initialise sess variable for the new session $sess = array(); $sess['user'] = test; $sess['var1'] = true; session_register('sess'); } session_start(); initSessionVar(); header('Location: http://localhost/test2.php'); exit; ? File test2.php ? session_start(); echo gettype($HTTP_SESSION_VARS['sess']) . BR; echo $HTTP_SESSION_VARS['sess']['user'] . BR; echo ($HTTP_SESSION_VARS['sess']['var1'] ? true : false); if ($HTTP_SESSION_VARS['sess']['var1']){ $HTTP_SESSION_VARS['sess']['var1'] = false; } else{ $HTTP_SESSION_VARS['sess']['var1'] = true; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database 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]