473,468 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

session works only in IE not in firefox

50 New Member
Hello all,
I am using sessions to authenticate users and to store their information (username n password).

login_pro.php page:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3. include("db_connect.php");
  4.  
  5.     $Rs=mysql_query("SELECT Pcc_username,Pcc_password,Pcc_fname,Pcc_lname FROM pcc WHERE Pcc_username='$pcclog' AND Pcc_password='$pccpwd'");
  6.  
  7.     $count=mysql_num_rows($Rs);
  8.  
  9.     if($count==1){
  10.  
  11.  
  12.         $_SESSION['username']=$_POST["txt_plogin"]; 
  13.         $_SESSION['password']=$_POST["txt_pwd"];   
  14.  
  15.         $row=mysql_fetch_array($Rs);
  16. ?>
  17. html..
  18. etc
  19.  
  20.  
and in my others pages i check if a session variable exist else i redirect the user to the login page

setup.php page:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3.  
  4. if ((!$_SESSION['username']) || (!$_SESSION['password'])){
  5. header ('Location: pcclogin.php');
  6. }
  7. ?>
  8. html...
  9. etc
  10.  
if the user has not login through the login page, then he will not be able to view the other pages and will be redirected to
pcclogin.php. This works perfectly fine in IE but not in firefox!! I can visit the other pages even if i have not login. I think that in firefox it stores the sessions..sumthing like that..
so what do i need to do to make it work in firefox too??? i have tried using session_register but still it does not work in firefox! plzz help
Mar 27 '09 #1
11 6589
eihabisaac
38 New Member
try using this.. it works fine with me using firefox and IE
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start(); 
  3.  
  4. if (($_SESSION['username']!= null) || ($_SESSION['password']!=null))
  5.   //do what ever you want
  6. else
  7. {
  8. header ('Location: pcclogin.php'); 
  9. }
  10. ?> 
  11. html... 
  12. etc 
  13.  
  14.  
Mar 27 '09 #2
poopsy
50 New Member
No it still does not work in firefox, I can still visit the pages even though i have not logged in.
Plzz help! what part is wrong in my code?
Mar 28 '09 #3
Markus
6,050 Recognized Expert Expert
I cannot replicate your problem, unfortunately.

Does FF have cookies enabled?
Mar 28 '09 #4
poopsy
50 New Member
Yeah cookies are enabled. I found out when i clear data in firefox, it clears authenticated sessions also. I can clear it to make it work each time. But the problem is I am doing this for a project, and it needs to work on any browser. Any idea about how i can implement this in some other way? i.e only members who have logged in can visit some pages and redirect others users to the login page??
Mar 28 '09 #5
TheServant
1,168 Recognized Expert Top Contributor
I think the general feeling is there is something wrong with your firefox. Have you tried it on any other browsers? Opera, Chrome, Safari?
You see if the control is from PHP, which it is, if it works on one browser, it is not your PHP, unless you have bad html output from it. Try it on other browsers, and if there are still problems, I suggest reinstalling FF.
Mar 29 '09 #6
dlite922
1,584 Recognized Expert Top Contributor
@TheServant
If I may, I have to disagree with Servant this one time only,

I had this same exact issue a few months ago. Funny thing was, all other sites worked fine. i.e FF was handling sessions for bytes, my bank, and all other sites, except my code.

I eventually got it to work, but don't remember what I did off the top of my head, I'll dig it up and post it here, if I find it.

All I know it wasn't any of the typical problems (e.g. sending http_header/data before start of session, etc)

It would be interesting to know if reinstalling FF does actually fix it for you thought. (Remember to disable/uninstall all addons/plugins)





Dan
Apr 1 '09 #7
TheServant
1,168 Recognized Expert Top Contributor
@dlite922
Interesting Dan, I hope you can find out what the problem was, because it could be a worth while piece of info if I, or anyone else come by a similar problem. More ideas of things to check is always worth remembering.
Apr 1 '09 #8
secmazec
34 New Member
Guys, unfortunately I can't see any problem in any code in here.

Also talking about cookies is irrelevant, I don't see any command working with it.

Fix your browser or replace invalid user :)

No offense, good mood ;)

You can simply test if your session works with this little code:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. $_SESSION['tester'] = 1;
  4. if(!$_SESSION['tester'])
  5.  echo "session doesnt work";
  6. ?>
  7.  
Apr 2 '09 #9
secmazec
34 New Member
Oh and I've forgotten, don't forget ! :)

To put session_start(); on top of each page, or @session_start(); to semi-include pages, to suppress exit; or die;
Apr 2 '09 #10
Markus
6,050 Recognized Expert Expert
Cookies are required to be enabled because, typically, a programmer will use cookie based sessions. The information is not stored in the cookie, but the session id is. That id is then used to access the information stored at the server. This is why cookies are required, unless you are using a session id in the url, for example.

Also, you should use isset() to check that a variable exists, not only is that the intended use of the function, but what if $_SESSION['tester'] had a value of (int) 0? The if() conditional would read that as false, giving a wrong (but technically right) answer.

Furthermore, instead of using the slow error suppression '@', it would be logical to check the session is set, via something like:

Expand|Select|Wrap|Line Numbers
  1. if ( ! isset ( $_SESSION ) ) session_start();
  2.  
Then again, you should have such an understanding of your code and it's 'flow' that you shouldn't need to restart a session that is already present.

- Markus.
Apr 2 '09 #11
secmazec
34 New Member
Don't fix what is not broken, please. I respect your oppinion and would be nice to see the same.

PHP is not exact language and there are always many ways to do some things. That's why I love it and I can programme in my own style.
Apr 2 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jeremy Epstein | last post by:
I've got a 4-page form that lets users enter a whole lot of information, which is then submitted and emailed at the end. All the fields are stored as session data. The whole thing works fine: ...
13
by: Alexander Widera | last post by:
hi, who has seen the follow problem or could help please? i visit a page .... i read a sesssion-var . ... everythink works...... i visit the page again..... error ... the sessionvar is null .... i...
0
by: shantibhushan | last post by:
Hi I am facing specific problem with firefox browser. I have integrated payment gateway in my website. it is working fine in internet explorer. But I am facing problem with firefox and opera...
9
by: cendrizzi | last post by:
Hi all, I've read some stuff on this but can't seem to come up with a solution that works right. I have a semi-mature (yet very large and robust) internal web application that currently only...
0
by: Oliver Heins | last post by:
Hello, I have a somewhat strange problem. The firefox browser on a mac (tested 1.5.0.4) hangs after the third or fourth call in a session. This happens both with cookies enabled and by passing...
4
by: rgparkins | last post by:
Hello I am running out of time with a problem I have running PHP 5.04 and Apache 2.0 and really need help :(. I have a page that stores a variable in session but each time I reload that page the...
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
4
by: avdbrink | last post by:
I'm building an application wich should be used by other websites inside an iFrame. My app stores some sessionvariables, but sometimes in IE (6 and 7) IIS seems to restart the session on each...
3
by: dihola | last post by:
Hi, I have a website running in IIS7 and it seems to be creating a new session for every request I make. The values I store in Session are lost with every request. This is the forms bit in my...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.