Re: Re: SESSION and include

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PROBLEM SOLVED!

What I actually was including was a variable ($main) and since some my pages are called on from different pages in different folders what I actually did was seting $main to the full URL to the site (http://mysite.com/page.php) to avoid confusion. But when calling on a URL I guess PHP is set to drop $_SESSION variables...

$main="../page.php";
require($main);
Works fine.

Thanks for all your time and help!
/Fredrik



Jochem Maas wrote:

your problem is probably the fact that when you include
page.php you are in effect calling session_start() twice -
no idea what that does to your session but I wouldn't be
suprised if that borked the _SESSION array.

TIP: create a 'global include file' that contains all the code
required by every 'page' (i.e. every request) and have each page
do a require_once on the 'global include' - below is a basic
example:

INDEX.PHP
>>>>>>>>>>>>
<?php

require_once 'global.inc.php';

// bla bla bla - do stuff

<<<<<<<<<<<<

GLOBAL.PHP
>>>>>>>>>>>>
<?php

session_start();

// do more repetitive 'init' stuff


<<<<<<<<<<<<

Fredrik Tillman wrote:

ok.. I was a little too fast again when explaining my problem.. Gonna put some code up for you to see...

First of all I DO use quotes. I tried both single and double ones (',")


I can't smell that from here though can I? but on the plus side you
have just learnt to cut and paste the real [problem] code as opposed
to writing out a similar bit of code as an example.

....


if($login_check > 0){
   while($row = mysql_fetch_array($sql)){
   foreach( $row AS $key => $val ){
       $$key = stripslashes( $val );


one has to wonder why you are needing to stripslashes on the values
you are retrieving from the DB ???

especially given that you then don't use the values you have just stripped.

you could remove this whole foreach loop and the
code would work indentically (based on what I can see here).

....


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux