Cookie and session issues in php / mysql / wamp

I use wamp for development on a Windows 7 machine. For this application, I have an administration area that tracks the administrator name and encrypted password with $ _SESSION and a cookie that tracks the randomly generated encryption key for the password.

I set the cookie as:

setcookie('key', $key, time()+7200, 'admin/'); 

Verification of the admin user is started on each admin page after the admin user has entered a username and password for logging in.

Directory structure of the site and administrator:

 localhost/mysite/ locahost/mysite/admin/ 

A session is run in the administration section, and a session is also run in the front-end user interface to track selected search criteria.

When I run long database queries in the admin area, i.e. several updates and inserts, where each iteration requires connecting to an external API, I can’t load the user interface in the same browser, i.e. firefox until the admin operation completes. If I use a different browser, i.e. chrome, I can load the front-end site while executing mysql admin functions without problems.

I want to browse the site while performing these operations and use the same browser. This is a small problem, but I would like to know how to get around it because I want to study. I mean, I can just tell myself that it doesn’t matter, because the site works fine when I open another browser, and the end user will not start administrator operations while viewing the site, so from that point of view it’s not “but I am curious.

What happens with sessions and cookies that prevent me from viewing the site while the administrator is working? Is my question even a good one? Part of me thinks this is a stupid question, because in the end the site works fine in a separate browser. Anyway, thanks for watching!

+4
source share
1 answer

I think your session is locked. On a page that takes a long time to start, add this at the top: session_write_close(); which should fix it.

+2
source

Source: https://habr.com/ru/post/1480276/


All Articles