[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: "; } 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 . "Your session ID is: $session_id"; } else { $message = $message . "Error: Failed to register session id into database."; } } else { $message = $message . "You already have a session id: $session_id"; } ?>
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: > > > > >session_id(); > >session_name(); > >session_register("username"); > >session_write_close(); > >echo(" >language=\"JavaScript\">window.location.href=\"admin/admin.phtml?<? > >php=SID?> > >\";"); > >?> > > > >Result: http://admin/admin.phtml? > > > >PHP doesn't display the correct SID. > >Instead the string 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?> > > 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
>-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: > >session_id(); >session_name(); >session_register("username"); >session_write_close(); >echo("language=\"JavaScript\">window.location.href=\"admin/admin.phtml?<? >php=SID?> >\";"); >?> > >Result: http://admin/admin.phtml? > >PHP doesn't display the correct SID. >Instead the string 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]
[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. next Result: http://admin/admin.phtml?PHPSESSID=85e6077fd4ff6bdd738707335f283ef5 2. function Test() { window.location.href="admin/admin.phtml?=SID?>"; } Result: http://admin/admin.phtml?PHPSESSID=85e6077fd4ff6bdd738707335f283ef5 And this doesn't work: window.location.href=\"admin/admin.phtml? \";"); ?> Result: http://admin/admin.phtml? PHP doesn't display the correct SID. Instead the string 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 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']) . ""; >echo $HTTP_SESSION_VARS['sess']['user'] . ""; >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]
[PHP-DB] Problem with session vars !
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 http://localhost/test2.php'); exit; ?> File test2.php "; echo $HTTP_SESSION_VARS['sess']['user'] . ""; 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]