Jump to content

Wierd warning that corrects itself... I think???


elmas156

Recommended Posts

I'm using WampServer to test php pages locally.  I just started having this warning message show up:

 

Warning: session_start() [function.session-start]: open(c:/wamp/tmp\sess_3c3f4g0dhb6qu007v167pv1u45, O_RDWR) failed: Permission denied (13) in C:\wamp\www\page_include\index.inc.php on line 2

 

The warning shows up and I am directed to the login page.  The funny thing is, when I refresh the browser, the warning goes away and the page is directed to the page the user is directed to after they are signed in.  I haven't changed any of my code since everything was working fine.  Is this a problem with WampServer or possibly something that I should be looking at changing my code to fix?  Any suggestions?  Thanks.

Link to comment
Share on other sites

The session file is probably already open due to one piece of your code and another piece of code attempts to open the same session file.

 

Any chance your page is using a captcha image where the main page and the code for the dynamically generated captcha image are both executing a session_start() or you are using Ajax and the code that the Ajax is requesting is using a session_start along with the main page?

Link to comment
Share on other sites

No, none of that.  In fact, I only have session_start(); on one file, which is included in the pages that are only accessible to signed in users, along with my database sign in information and a few other variables that remain the same during the session.  I do, however use the following if statement to display certain information if the user is signed in:

 

if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) {

 

show this

 

} else {

 

show this

 

}

 

This is used on a couple of files that are included on every page.  Other than this, the session is not mentioned any where else on any of the pages.

Link to comment
Share on other sites

Am I correct to put session_start at the top of every page that the user will view while signed in?  That is what I've been doing, and, like I said, this warning just suddenly started showing up, and it's only an occasional warning, I can even click the browser back button and re-click the same link and it will go to the appropriate page rather than show the warning message again.  It's very odd.

Link to comment
Share on other sites

I'm going to guess that your browser is requesting the page twice (this usually happens due to a debugging add-in in your browser) and it occasionally occurs fast enough that the second request is being serviced before the first request has completed and released the session data file.

 

You need a session_start() statement on any page the sets or references a $_SESSION variable.

Link to comment
Share on other sites

So, do you happen to have a debugging add-on installed in your browser and if so, when you disabled it, did the problem still occur?

 

If this is being triggered by double-requests from your browser, it could also be an indication that your page is doing something extremely inefficient and is taking a long time on the server to produce the page.

Link to comment
Share on other sites

Well, I'm using Firefox 4, which is a beta version.  I think it had something to do with the browser because it's not happening at all now, even if I try to make it happen.  I don't think it ever happened in IE either.  As far as inefficiency, I don't think that is the case.  What I am doing now that I know a little more about php and how it works, I'm re-doing my entire site with the intention of making it more efficient by cleaning up my code.  I've removed a lot of un-needed code and it does seem to respond faster as well.  I'll see how things go and if the problem re-occurs.  Thank!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.