platform: IIS + Apache + mysql + php (please dont justdge me on the platform it was not my choice)

I have this weird bug that seems to be directly related to my sessions on my web based app.

when i travel between links, if i give the previous page enough time to fully load i am fine, but when traveling from page to page if i click another page link before the previous one has finished loading then i suddenly get kicked back tot eh login screen. I dont understand why this is happening and i cant seem to find much about it online anywhere either.

Oh please great wisdom of the daniweb members, here my call, answer this ulcer inducing question i have been stuck on for days.

Thank you for all of your assistence!

Recommended Answers

All 10 Replies

Define "fully loading."

Are we talking about a page built dynamically with AJAX? All server side? Are you doing redirects inside your script when you change to the new page? Just a refresh? Is it with all pages or just specific pages? If specific pages, are you doing something to the session on those pages? Are you sure session_start() is the very first line of every php page?

Your question has so... so many variables. Either give some example code to look at, give an example page to see if we can replicate, or be a bit more specific please.

Side note: nothing wrong with your setup. Who cares that you're using MySQL with a Windows server? ;-) As long as it works, and works for you, the setup is irrelevant.

i will try to give an answer to every variable, im a bit tired lol so try to bare with me if something sounds weird

The pages are all built server side
i am doing href redirects through an html navigation bar i built
its not on a refresh that doesnt seem to hurt anything for some reason
it si all the pages, no matter where im coming from
and yes i use a sec_session_start function at the top of every page literally EVERY page

and the reason i said that about the platform is because i went to a convention not to long ago and got some serious dirty looks and commetns for using what is essentially open source on a microsoft platform.

finally, thank you for the quick response! :D

are the href's absolute path or relative path urls? If absolute, are they consistent? (http/s, www or no www? Same domain or sub domain?).

You will always have purists and evangelists for one thing or another. Let them howl and cry foul. If you stuff works, it works. Don't let fanboys dictate your life choices unless you want to be a fanboy yourself (which is also ok).

the hrefs are relative paths

I try my best to be neutral about those subjects because no matter which side you pick you will always end up pissing someone off in the end. I prefer linux though but mainly because its free and the community (like daniwebs) is great ^ u ^

Ok.. so how are the pages "not fully loaded" when you navigate? I assume the hrefs are just attached to anchor tags?

they are, and please excuse my lack of detail but ill describe this the best i can.

when clicking the href link and going to another page, while the new page is loading before it begins loading the new page i have time to click another link which will cause it to pause for a second and then it will kick me out, or at least i know my sessions are being destroyed which is causing the kick

Why such a long delay between page navigations? What are those links doing?

I have a very old and very slow server :/ i always thought that was normal since im running on such old hardware and slow disks

Well, it very well can be old hardware... but.. anyway...

Things that destroy sessions:

-302 server side (a redirect from code).
-Non relative links.
-session_destroy()
-overriding the $_SESSION superglobal (say, assigning it as a variable, and not just a member of the super global. ex: $_SESSION = NULL instead of $_SESSION["User"] = NULL).
-Pretty much anything that sets a header before session_start() is called (which means, in that fancy dancy session function you have, it may be doing some work that happens twice before session_start() actually get called or completed.)

Lastly.. it is entirely possible that your hardware is so strangely slow that by clicking a link before the script has finished executing the next page that a redirect header is output (you will have to check your network activity), and thus destroying your current session by putting a new on that is set after the header is output.

If it's none of that, it might require a peek at your code to see what's up :-/ Or a server configuration...

i think those first few items might be what im looking for, i never really thought to look back through the function i created but now i feel like i need to revisit it. Ill keep you posted on any updates, again thank you so much for your assistance! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.