Jump to content

What have i done? =/


SirChick

Recommended Posts

I think this is related to sessions lol. I have a question about it as im getting session errors all over the place and ive had 2 people who i was going to pay to fix this still couldn't work it out and concluded that my code has mind of its own but i think i might have found it but i thought id double check with you guys.

 

This is going to a bit long winded but its the only way i can explain...

 

Basically say i have a page as "test"

This "test" has 2 includes "globalinclude" and "variableinclude"

Now in "globalinclude" i have:

session_Start()

 

(globalinclude is and has to be on every page of the site)

 

But in "variableinclude" i have the globalinclude as an include for that aswell for above reasons in bold... so is my "test" page effectively just loading the session_start() twice?

Thus causing the error?

 

This is my error but although it's self explanatory i don't have session_start() written twice any where.. so my only guess is the page is loading the one include twice because its also included on the second include lol =/

 

I got this on my page:

<b>Notice</b>:  A session had already been started - ignoring session_start() in <b>C:\xampp\htdocs\include.php</b> on line <b>2</b><br />

<br />

<b>Notice</b>:  A session had already been started - ignoring session_start() in <b>C:\xampp\htdocs\include.php</b> on line <b>2</b><br />

 

<b>Warning</b>:  Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in <b>Unknown</b> on line <b>0</b><br />

 

 

If it is the double loading of the session, how else can get around that? Because the global include has to be there for it to allow the script to work... because it does a check if session has not started die and echo "you must be logged in"....

 

I been having this problem all week so any thoughts on this is much appreciated.

Link to comment
Share on other sites

but then the include will log me out .... cos if the session is empty itll say "you must be logged in " ...

and that is the only session_start(); you see? But because its include in a long strange way twice it could be reading it a second time and giving me an error you get me ? But im unsure if that would occur..

Link to comment
Share on other sites

Yes, it is because you are including it twice. Why not just include the one file that has both the files you need in it at the top of the page, then get rid of the include that you call on all your pages since that is already included in the other file?

 

 

 

that is such a good point lol!!!!! I have done it but i got this still:

 

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

 

 

 

Link to comment
Share on other sites

Let's deal first with the Notice.  It's NOT an error, it's notification in your case that your code attempts to start a session a second time. If you read the notice, you'll see that the php parser simply ignored your coding error and just advised you.  Solution - don't use session_start more than once in a script, including any includes called by the script.

 

Now let's deal with the register_globals issue.  Once again it's NOT an error, it's a warning.  Warning you that somewhere in your script you are using a variable without acquiring it via GET or POST (for example) and instead assuming that it existed in the global space. That used to be true in old versions of php; not anymore because register_globals is set to OFF by default.

 

No comment on paying two people to fail to even recognize the problems given the obvious nature of the notices and warnings.

Link to comment
Share on other sites

... obviously they were probably trying to swindle me lol

 

Looks like it.

 

So the warnings are nothing to worry about then

 

Unfortunately not true. They're warning you of a problem which one day soon might become a real headache.  Better to fix it while you're on a hot streak (and so it'll work if your host upgrades php)

Link to comment
Share on other sites

somewhere in your script you are using a variable without acquiring it via GET or POST

 

But thats suggesting ALL variables must be created via forms

 

... or from cookies or from sessions or via URL links or from a database, etc.

 

There are quite a few people who manage quite nicely without assuming globals are on.

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.