visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: PHP & Sessions


By: trican U.S.A.  Date: 29/06/2003 00:00:00  English  Points: 100 Status: Answered
Quality : Excellent
Hi,

I'm designing a multi user site and am making use of sessions. Being somewhat of a newbie I'm encountering odd results which i dont understand. Basically on a test machine the login procedure works and the session variables are carried through the site, however on a laptop test machine the session doesnt really seem to start. For example after loging in on index.php, with a basic form, the user is redirected to a page (log.php) that starts the session, with roughly the following code...

session_start();
header("Cache-control: private");
[snip]
// password verifcation and database accessing
$fname = $row["fname"];
$sname = $row["sname"];
session_register("fname", "sname");

The user is can then clicks to go back to the index.php, at the top of this file is the usual code...
session_start();
header("Cache-control: private");


In typcial fashion on a side navigation bar , i check if one of the session variables is registered, and if so display user profile information else display the login form....i'm basically doing this with

if (isset($_SESSION['fname']))
{
//output user logged in options
}
else
{
//output the login form
}

This configuration works fine on my desktop but as i said on my laptop i never see the "user logged in options". weird????

btw cookies are enabled on both machines.

Any help would be appreciated.
thanks
By: VGR Date: 29/06/2003 19:35:00 English  Type : Comment
isn't the laptop running a different PHP version than the first machine ?
isn't register_globals setting different on the two machines ? :D


try to use $_SESSION['fname'] as a refere,nce to the session variable, like this :

"$_SESSION['fname']=somevalue;" in stead of "$fname=somevalue; session_register('fname'); "
By: trican Date: 29/06/2003 19:53:00 English  Type : Comment
well the weird thing is that I'm accessing the site from the hosting server from both the laptop and desktop, so php versions and settings have to be the same.

I did the change as you suggested. So its proceeds from index.php to log.php and gives a postive result on the log in page eg...

echo $_SESSION['fname'];
echo $_SESSION['sname'];

outputs the first name and surname of the logged in user, however when i return to index.php it branches to the else part of the test below

if (isset($_SESSION['fname']))
{
//output user logged in options
}
else
{
//output the login form
}


????
By: VGR Date: 29/06/2003 19:59:00 English  Type : Comment
are you ***sure**** there is a session_start() at the beginning of the index.php ?

Andthe two pages, are they on the same domain ? (ie, not <A HREF="http://someserver.tld">http://someserver.tld</a> and <A HREF="http://someother.tld">http://someother.tld</a>)
By: VGR Date: 29/06/2003 20:00:00 English  Type : Comment
I mean, in the "side navigation bar" :D
By: trican Date: 29/06/2003 20:18:00 English  Type : Comment
yeah....i have a "library" file with a function called outputheader(). Its purpose is to do the first few lines of the html, header, body and set up colours etc but the very first line is session_start(). Its called from every page on the site. index.php calls this function first and then calls a function printSideBar() which has the IF condition.


Also it must be there if the log in works on my desktop? And both desktop and laptop are using the same version of IE?

And the two pages are on the same domain - albeit a lycos free hosting domain.

Confused!
By: VGR Date: 29/06/2003 20:20:00 English  Type : Comment
ha ha 8-)

then I know why 8-))))

in the function printSideBar(), add this veru first line :
GLOBAL $_SESSION;




:D
By: trican Date: 29/06/2003 20:34:00 English  Type : Comment
still doesnt work :-(

why would it work on one machine and not the other?
By: VGR Date: 29/06/2003 20:53:00 English  Type : Comment
difference in browser (IE6 unpatched is crap as for HTTP headers like cache-control, refresh rates, etc and for sessions)

or

difference in internet gateway (proxy/cachemanager/firewall)
By: trican Date: 02/07/2003 05:58:00 English  Type : Comment
Sorry for not replying sooner....

downloaded and installed IE6 service pack 1 and Opera - ran both on my laptop and am still seeing same problem on both.


gateway etc....
not this either, I switched the ethernet cable from my desktop to laptop - still same problem?



By: trican Date: 07/07/2003 23:48:00 English  Type : Comment
still having this problem??? so I've increased the points
By: VGR Date: 08/07/2003 00:07:00 English  Type : Comment
sorry, I'm no magician ;-)
By: trican Date: 08/07/2003 00:28:00 English  Type : Comment
fair enough - but i'll leave the question open for a bit longer just in case someone else has any thoughts. cheers anyway

Do register to be able to answer

EContact
browser fav
page generated in 2224.378820 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page