Closed Thread Icon

Topic awaiting preservation: My php code keeps making sessions and I don't want it to Pages that link to <a href="https://ozoneasylum.com/backlink?for=12807" title="Pages that link to Topic awaiting preservation: My php code keeps making sessions and I don&amp;#039;t want it to" rel="nofollow" >Topic awaiting preservation: My php code keeps making sessions and I don&#039;t want it to\

 
Author Thread
marf
Bipolar (III) Inmate

From: Canada
Insane since: Oct 2001

posted posted 07-03-2003 19:52

ok when this page loads.. it automatically opens a PHP Session and has a shit load of crazy numbers are behind the address in the Address bar... can anybody help me?

code:
<?php
//Standard header

//gets the file with standard functions in it.
require("main2.php");

//setting the type of page.

$pagetype="basic";

displaypage($pagetype);


//this file contains the standard functions

function displaypage($pagetype) {

//this function grabs the html file and begins to print it.
//When it reaches the dynamic parts of the page separate functions are called.


$htmlfile=file("sitecontent/page.html");
for ($i=0;$i<=sizeof($htmlfile);$i++) {
if (strstr($htmlfile[$i],"<!----Begin Site Content--->")) {
maincontent($pagetype);
}
else {
print($htmlfile[$i]);
}
}
}
?>



I think is has something to do with the pagetype="basic"

Any help?

[Emp edit: kill HSBoD]

[This message has been edited by Emperor (edited 07-03-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-03-2003 20:22

marf: I have had that problem - it adds something like &PHP_SESSID=12121212121212121212121212

I think it is something to do with your settings - I'll have a dig around (hopefully someone else will jump in before I get back).

___________________
Emps

FAQs: Emperor

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-03-2003 20:40

I'd bet a black pill that in the file called 'main2.php' there will be a call to session_start() or session_register(), or alternativly that
ini_get ("session.auto_start") will return 1 (=True, meaning on).

As for the 'appending session id to url',
probably ini_get("session.use_trans_sid") will yield 1 as well.

if this is the case, you might be able to turn it of with an entry into a .htaccess file
refer to the user comments on this manual page for that.

Now, what ever happend to those cookies that inmates kept on passing out?

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-03-2003 21:23

Mr Prime: Again you are on the money - I'll find a cookie for you..............

Try this in your .htaccess file to fix it:

code:
php_value session.use_trans_sid 0



[edit: Yep I tried it and it will turn the 'local value' to 0]

___________________
Emps

FAQs: Emperor

marf
Bipolar (III) Inmate

From: Canada
Insane since: Oct 2001

posted posted 07-03-2003 22:21

I knoe for a fact that in main2.php has nothing to do with the problem. here is coding in main2.php

code:
<?php
//this file contains the standard functions

function maincontent($pagetype) {

if ($pagetype=="basic") {
?>
<a href="index.php">test</a>

<?php
}
}
?>



and its like exactly like what Emperor said.. when u roll over a link or lcick on it has that PHSEESS and all those numbers.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-03-2003 23:11

marf: I'd need to check but I'm pretty sure I have seen it appear on pages without any sessions too (although I do use a lot so I could have sneaked one in somewhere ). Weirdly the extra bit of querystring seems not to appear consistently put just pops up every now and again. Very odd. Anyway - what I give above should fix the problem. If it doesn't let us know and we'll try again

___________________
Emps

FAQs: Emperor

marf
Bipolar (III) Inmate

From: Canada
Insane since: Oct 2001

posted posted 07-03-2003 23:49

also, where is the .htaccess file located??

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 07-04-2003 00:12

If as TP says the session.auto_start and session.use_trans_sid are set to yes in the php.ini file, the session id is probably being appended to the <a href> tag in the main2.php file even though it's not coded that way.

If a=href is one of the values set for url_rewriter.tags in your php.ini file, this will automatically append the session_id to any <a> tag, or whatever other values are set in that line.


-Butcher-

marf
Bipolar (III) Inmate

From: Canada
Insane since: Oct 2001

posted posted 07-04-2003 00:43

So i want to go into my php.ini file and turn sessions off?? BUt I also run a yabbse Forum from that server.. and by turning them off for all PHP.. wouldn't that make the forum not work.. because it uses sessions in its coding??

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-04-2003 02:05

marf:


quote:
where is the .htaccess file located??



It lives in the root of your web site (where you main index/default page goes). You might have one already but some FTP software doesn't pick them up - SmartFTP (which is free for non-commercial use) does. If you don't already have an .htaccess file:

To create one open Notepad (or an equivalent) and copy and paste the line of code I gave you above into the file. Save it as something like htaccess.txt and upload it your root. Then change the name o .htaccess (note the dot - it is actually an extension with no filename). This should fix your problem without having to turn sessions off (actually you don't have to turn them off jus stop them from automatically starting - you can still start them in code).

___________________
Emps

FAQs: Emperor

marf
Bipolar (III) Inmate

From: Canada
Insane since: Oct 2001

posted posted 07-04-2003 04:47

Ok.. heres what I've done so far

I have put a .htaccess file in the root of my webpage and still i get the sessions

I have tried editing the php.ini file on my server.. and turnin the registered global variables off..
still sessions

the code for my scripts are above and as you can see.. neither of them have script in them to Open a Session.. so I don't really know what else to do.

Any advice?

anything else I can chance in the php.ini file?

some line of code I can insert in the index.php or main2.php that Disables or Closes sessions before or after they have started??

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 07-04-2003 13:42

marf

Try putting:

ini_set('session.auto_start', 0);

at the top of your scripts that are giving you problems and see if that takes care of things.

As for making changes to your php.ini file beware that the scripts you are running my need the settings to be the way they are. For example, if your scripts aren't using GLOBAL variables throught (i.e. $_POST, $_GET, $_SERVER) your scripts won't work properly with register_globals turned off. The line of code above I suggested you try will alter what's in the php-ini file without actually changing it. It will change the setting only for the pages that the code is on, but not for any other pages.

I hope this helps.

-Butcher-

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-04-2003 18:34

if neither of that works, make a test case.

make a test.php,
put
'<a href="test.php">test</a>' into it. see if it get's appended. try other variations of the link tag.
Also check with a browser that'll display you the cookies that are being send, wether the site tries to set one.

then we should be able to locatet this a bit further.

so long,

Tyberius Prime

marf
Bipolar (III) Inmate

From: Canada
Insane since: Oct 2001

posted posted 07-04-2003 23:45

Ok obviously something is screwed with my code.. Basically i'm making a website and I have a side bar and top bar. Now I want to have the content in the middle..But lets say when I change a link on the side bar,, I don't want to have to visit each individual page and change the link manually, I want the left and top bars to be in a template page, and when the user clicks on a link, I only want it to load the content into the middle. Can anybody point me to a tutorial where I can find code like that?

« BackwardsOnwards »

Show Forum Drop Down Menu