473,396 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with Firefox/Mozilla and Cookies.

Hi,

I am having a problem with my program which only happens when using
Mozilla or Firefox.
The pages I wrote, are part of a private web directory, a service
offered by the ISP, which upon configuration, restricts its access
only to users registered on the site. So then once the user signs in,
the entry point of the user to my pages, has access to a cookie
(site_<some number>) set by the validation program. I can use the
values in this cookie to retrieve the user_id, and some other code
that I need to query a databata to find out the user access level to
the site (administrator, plain user, etc...). It works fine, the
problem happens if the a user using any of the Mozilla browsers, (1)
Logs on to my site, surf around, and (2) without closing the window
goes somewhere else (e.g.: www.google.com, or www.yahoo.com), and then
(3) again without closing the window comes back to my pages using by
retyping the same URL he used to access my page at the beggining. When
he tries this, the validation system lets him in without any having to
log in again, but I loose all the cookies and session variables,
therefore I no longer know their user_id and code to access the
database.
I checked the browser configuration and the cookies are set to last
until the browser window is closed, but seems like is not doing that.

Here is a snipet of my code that retrieves the cookie:

session_start();

if(isset($_COOKIE["site_2400067262"])){
$site_cookie = $_COOKIE["site_2400067262"];
list($u,$l,$md5p,$user_oid,$pref_datetime,$perms_d atetime,$pl) =
explode("&", $site_cookie);
$u_name = split("=", $u);
$u_login = split("=", $l);
$u_oid = split("=", $user_oid);
// In case the cookie is not available, save its value in session
variable...
$_SESSION["u_name"] = $u_name;
$_SESSION["u_login"] = $u_login;
$_SESSION["u_oid"] = $u_oid;

} else {
// Retrieve the session variables if the cookie is not available
$u_name = $_SESSION["user_name"];
echo ("u_name is ".$u_name);
$u_login = $_SESSION["u_login"];
$u_oid = $_SESSION["u_oid"];
}
$isAdmin = false;
if (isset($u_oid[1])){
$db = mysql_connect("www.kidswithfoodallergies.org:3306" ,
"kidswitror_rcp", "allergenfree");
mysql_select_db("kidswitror_eve",$db);
$sql = "SELECT GROUP_OID FROM IP_GROUP_USERS WHERE USER_OID
=".$u_oid[1].";";
$result = mysql_query($sql) or trigger_error(mysql_error(),
E_USER_ERROR);
while($row = mysql_fetch_array($result, MYSQL_NUM)){
if (($row[0] == $KWFAAdmin) || ($row[0] == $RecipesInOurDB) ||
($row[0] == $RecipesDBTeam)){
$isAdmin = true;
break;
}
}
}
$_SESSION['user_name'] = $u_name[1];
$_SESSION['user_login'] = $u_login[1];
$_SESSION['user_oid'] = $u_oid[1];
$_SESSION['isAdmin'] = $isAdmin;
$_SESSION['frompage'] = 'introduction';
$_SESSION['db_result'] = $result_array;
$_SESSION['total_rows'] = 0;
$_SESSION['category'] = '';
session_write_close();
?>
So the second time around the site_cookie is no longer availble , and
I fall on the else, but all of the session variable are gone.

Has anyone ever experienced something similar ?

I'd appreciate any help on this.
M.D.
Jul 17 '05 #1
4 3022
m6**@hotmail.com (M.D.) wrote in message news:<e0*************************@posting.google.c om>...

I did not go deeply into your code, but I think that problem in this
part:
if(isset($_COOKIE["site_2400067262"])){
$site_cookie = $_COOKIE["site_2400067262"];
list($u,$l,$md5p,$user_oid,$pref_datetime,$perms_d atetime,$pl) =
explode("&", $site_cookie);
$u_name = split("=", $u);
$u_login = split("=", $l);
$u_oid = split("=", $user_oid);
// In case the cookie is not available, save its value in session
variable...
$_SESSION["u_name"] = $u_name;
$_SESSION["u_login"] = $u_login;
$_SESSION["u_oid"] = $u_oid;

} else {
// Retrieve the session variables if the cookie is not available
$u_name = $_SESSION["user_name"];
echo ("u_name is ".$u_name);
$u_login = $_SESSION["u_login"];
$u_oid = $_SESSION["u_oid"];
}


What is "site_2400067262"? Why you checking this? It's doesn't looks
like PHP Session Id. When login - store some login flag in session and
check it every time. But this is not the best way to use SESSIONS for
password protected areas...
Jul 17 '05 #2
Hi Paul,

site_2400067262 is an unique cookie which the isp system set upon the
validation of the user on the system. It contains information about
the user name and user id, which I later use to retrieve some
additional data from the database.
With some further investigation (by echoing session_id()) I found out
that it seems that Mozilla and Firefox sets new session Id everytime
that the user leaves the pages and comes back by retyping the URL on
the address box. So that is why I loose the cookie and any session
varible that I set.
So my problem is that the mozilla based browsers do not retain the
same session_id.

Any suggestion on how to get around this ?

Thanks,

M.D.

pa****@mail.ru (Paul Yanchenko) wrote in message news:<6a**************************@posting.google. com>...
m6**@hotmail.com (M.D.) wrote in message news:<e0*************************@posting.google.c om>...

I did not go deeply into your code, but I think that problem in this
part:
if(isset($_COOKIE["site_2400067262"])){
$site_cookie = $_COOKIE["site_2400067262"];
list($u,$l,$md5p,$user_oid,$pref_datetime,$perms_d atetime,$pl) =
explode("&", $site_cookie);
$u_name = split("=", $u);
$u_login = split("=", $l);
$u_oid = split("=", $user_oid);
// In case the cookie is not available, save its value in session
variable...
$_SESSION["u_name"] = $u_name;
$_SESSION["u_login"] = $u_login;
$_SESSION["u_oid"] = $u_oid;

} else {
// Retrieve the session variables if the cookie is not available
$u_name = $_SESSION["user_name"];
echo ("u_name is ".$u_name);
$u_login = $_SESSION["u_login"];
$u_oid = $_SESSION["u_oid"];
}


What is "site_2400067262"? Why you checking this? It's doesn't looks
like PHP Session Id. When login - store some login flag in session and
check it every time. But this is not the best way to use SESSIONS for
password protected areas...

Jul 17 '05 #3
m6**@hotmail.com (M.D.) wrote in message news:<e0**************************@posting.google. com>...
site_2400067262 is an unique cookie which the isp system set upon the
validation of the user on the system. It contains information about
the user name and user id, which I later use to retrieve some
additional data from the database.
With some further investigation (by echoing session_id()) I found out
that it seems that Mozilla and Firefox sets new session Id everytime
that the user leaves the pages and comes back by retyping the URL on
the address box. So that is why I loose the cookie and any session
varible that I set.
So my problem is that the mozilla based browsers do not retain the
same session_id.

Any suggestion on how to get around this ?


What's about expiration date in cookies, setted by ISP? In
mozilla/firefox you can watch particual cookie.
Jul 17 '05 #4
m6**@hotmail.com (M.D.) wrote in message news:<e0*************************@posting.google.c om>...
<snip>
(3) again without closing the window comes back to my pages using by
retyping the same URL he used to access my page at the beggining. When
he tries this, the validation system lets him in without any having to
log in again, but I loose all the cookies and session variables,
therefore I no longer know their user_id and code to access the
database.


In that case, obviously the problem is with your authentication
script. How, could it allow when there is no cookies and no session??
Perhaps you may want to look at
<http://www.google.com/search?q=php+login>

Also, you may want to be specific about your browser versions, etc?
Check if it is specifically blocking any cookie values.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Neil Zanella | last post by:
Hello, I just ran into an interesting problem with cookies while using PHP 4 and Mozilla 1.6. Basically, I have been using PHP on a site called: foo.bar.net?script.php Within that script I...
7
by: patbaudy | last post by:
Hi, I'm coding a shopping cart in asp. I store all info about ordered items, customer's coordonates, etc...into cookies. When the order is complete I use "CDONTS.NewMail" to send an order...
4
by: Diffident | last post by:
Hello Guys, I am posting my weird experience on firefox by a piece of code I have written. That piece of code is supposed to be executed when the page is not posted back i.e., for the very first...
2
by: CalSun | last post by:
Greetings, I want users to browse the site with IE since my pages are not well displayed in firefox. I created a client script and hooked it to a Redirect button. This button will show as users...
1
by: ticmanis | last post by:
Hello, I'm having trouble getting MSIE 6.0 (running on XP SP2) to accept a cookie which works fine in both Firefox and wget. The web server is Boa 0.94.13 (a small embedded server) using PHP...
0
by: osa | last post by:
I have a problem with commons-httpclient-3.1. When i try to get some page, cookies do not come to me. There is no error or exception message. Just null text. What could you advise me? Code:...
3
by: lawrence k | last post by:
This site was working: http://www.thesecondroad.org/ Now I'm told people are unable to create new accounts or log in. One theory: It seems that cookies are not being set. Our beta testers...
1
by: bruce | last post by:
Hi. Got a test web page, that basically has two "<html" tags in it. Examining the page via Firefox/Dom Inspector, I can create a test xpath query "/html/body/form" which gets the target form for...
0
by: madhusvuce | last post by:
I’ve developed a website using ASP.NET 2.0 & deployed it on IIS 6.0.I’m using Cookies to store user related information. The expiry of this cookie is set for ‘7’ days. In IIS one new application pool...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.