Session problems with FireFox, not IE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Session problems with FireFox, not IE

Post by Citizen »

On the login page, I have this code at the top of the page:

Code: Select all

<?php session_start(); ?>
Followed by this code for the login:

Code: Select all

$sql="SELECT * FROM `accounts` WHERE name = '$username' AND passworddb = '$password'";
$result=mysql_query($sql) or die(mysql_error());
$number = mysql_num_rows($result);
if ($number == "1") {
session_register("password");
session_register("username");
The user logs in fine.

But.... once I load up my next page, the user isnt logged in anymore. The next page has this code at the top:

Code: Select all

<?php session_start(); ?>
Followed by this code:

Code: Select all

<?php
$sql="SELECT * FROM `accounts` WHERE name = '$username' AND passworddb = '$password'";
$result=mysql_query($sql);
$number = mysql_num_rows($result);
if ($number == "1") {
Do I need to do something different with the session varibles? It works in IE but I have to login again in FireFox.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

Code: Select all

session_register("password");
session_register("username");
try using

Code: Select all

$_SESSION['password'] = 'pass';
$_SESSION['username'] = 'username';


//on next page
$pass = $_SESSION['password'];
Post Reply