News:

Wondering if this will always be free?  See why free is better.

Main Menu

Custom php pages keep kicking me out of SMF

Started by rcane, March 05, 2023, 07:43:47 PM

Previous topic - Next topic

rcane

I had made some custom php/mysql CRUDs.

After each was done, if successful, you'd get a refresh and sent back to the main page of SMF.

Today I had to do a re-install and put some things back together.

And, now, I'm forced to re-login after each one of those previously successful transfers.  I've tried clicking the always stay logged in, but it's having no effect.

Any ideas?  Only the database was backed up and the theme re-installed.  My personal php pages are unchanged.


I tried it with two different admin accounts, and as long as they used a private browsing window it worked, but as soon as I got back to my normal firefox window they'd get re-directed immediately to the login on refresh of my php page.


live627

messin with cookies? Perhaps post some code.

rcane

Quote from: live627 on March 06, 2023, 01:57:22 AMmessin with cookies? Perhaps post some code.

Hi,

I've noticed that firefox & safari (so far) don't seem to hold the session.  Chrome worked in both normal and incognito.  Firefox might be working in private.


fwiw, I include_once on this create page, the SSI.php and my db.php.

This is the post code which is nothing special.  On it's way back to index.php it stops by the SMF log in screen--but you get directed to the index of smf after that.   I have a few other pages like this and I'll check them.

Cookie name is as it came during install--never touched it.
Default SMF cookie is 60 minutes;
Enable local cookie is UNCHECKED (sounded like I should have it that way since I use SSI a bit);
Use sub-domain independent cookies is UNCHECKED;
Force cookies to be secure is CHECKED;
Basic authentication is UNCHECKED;
Database driven:  CHECKED;
Cached pages: CHECKED
second: 3000

I tried local cookies checked but no success.

I've had so many pages work flawlessly for a year I can't see this not being a cookie problem that finally caught up.

SMF is in the root of the domain, so all my pages are under that:   example.com/blah/index.php

  if (isset($_POST['submit'])) {
    $thedate = $_POST['thedate'];
    if(empty($_POST['thedateend'])) {$_POST['thedateend']==$thedate; }
 
    if(empty($_POST['voltime'])){ $_POST['voltime']== "0"; }
    if(empty($_POST['expamount'])){ $_POST['expamount']=="0"; }
    if(empty($_POST['voldesc'])){ $_POST['voldesc']==" "; }
    if(empty($_POST['expdesc'])){ $_POST['expdesc']==" "; }
    $stmt = $conn->prepare(" INSERT INTO timecards (id_member, firstname, lastname, thedate, thedateend, voltime, voldesc, expamount, expdesc) VALUES (?,?,?,?,?,?,?,?,?) ");
    $stmt->bind_param('sssssdsds', $who, $fn, $ln, $thedate, $thedateend, $voltime, $voldesc, $expamount, $expdesc);
     
     $stmt->execute();
     


     if  ($stmt->affected_rows===1) {
       
         ringringtimecard($fn, $ln);
         header('Refresh: 0; URL=http://example.com/timecards/index.php');
   
       
     } else {
        //echo 'bad';
     }
     
     $stmt->close();
     $conn->close();
     
  }


Arantor

Try enabling subdomain independent cookies.
Holder of controversial views, all of which my own.


rcane


Arantor

Once you did this, log out and log back in to get new cookies.
Holder of controversial views, all of which my own.


rcane

#6
Quote from: Arantor on March 06, 2023, 08:43:23 AMOnce you did this, log out and log back in to get new cookies.

I did.  Went to the page, and it still kicks out.

I also noticed that, when it kicks out, the URL is for that /timecards/index.php still.

But, if I click the site header logo in the top left, it goes to the main smf page with no trouble.


Arantor

Then I don't know how you've broken it. Without further information it's impossible to debug.

Best guess, try recording the entire process of logging in, browsing around, going to custom pages and back to the forum, as a HAR file and see what cookies are actually submitted with each request.

I wouldn't be surprised if there's a domain or subdomain issue here.
Holder of controversial views, all of which my own.


rcane

Quote from: Arantor on March 06, 2023, 09:12:52 AMThen I don't know how you've broken it. Without further information it's impossible to debug.

Best guess, try recording the entire process of logging in, browsing around, going to custom pages and back to the forum, as a HAR file and see what cookies are actually submitted with each request.

I wouldn't be surprised if there's a domain or subdomain issue here.

I think I had a problem with an include/require with SSI.   Not sure how that got fouled up since it worked fine for months.  But, I'm still checking it with different browsers/devices/etc.

Thanks for the input--as always.

rcane

I've still heard of one person having issues, but it could be cookies on their end. 

Advertisement: