473,799 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

session checking for login

28 New Member
Hi theScripts!
I have a problem with my session.

When user login in my site, the session will save the user name and password. In my Login.php I have:
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2.      $qr="SELECT*FROM tbllogin WHERE nama='$_POST['nama']' AND password='$_POST['password']' ";
  3.     $res=mysql_query($qr);
  4.     $row=mysql_fetch_assoc($res);
  5.    $num=mysql_num_rows($hasil);
  6.  
  7.     if($num!=0)
  8.  
  9.     {    
  10.     $Username="$row[nama]";
  11.     $Passwd="$row[password]";
  12.     session_register("Username","Passwd");
  13.     header ("Location: Home.php");
  14.     }
  15.     else
  16.     {
  17.         header("Location:LoginFailed.html");
  18.     }
  19.  
And everything is fine. The session is saved, because I've checked it C:\webserver\Ap ache2.2\bin\php \datasession (it is the directory where my session.save_pa th refers to.)

Then, in my Home.php I have:
Expand|Select|Wrap|Line Numbers
  1. include "ceksesi.php";
  2. // bla bla
  3.  
In ceksesi.php I have:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. if(!session_is_registered(Username) && !session_is_registered(Passwd))
  4.   {
  5.      header("location:Login.html");
  6.   }
  7. ?>   
  8.  
When Logout is pressed, the session is deleted (also, the file in ...\datasession is deleted )
Here is the code of my Logout.php :
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. session_unregister("Username");
  3. session_unregister("Passwd");
  4. session_destroy();
  5.  
The problem is, the user can open the Home.php without login. Is there any suggestion? I don't know what's wrong with my ceksesi.php.

Thanks b4...
Sep 26 '07 #1
2 1755
momogi
28 New Member
Hi theScripts!
I have a problem with my session.

When user login in my site, the session will save the user name and password. In my Login.php I have:
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2.      $qr="SELECT*FROM tbllogin WHERE nama='$_POST['nama']' AND password='$_POST['password']' ";
  3.     $res=mysql_query($qr);
  4.     $row=mysql_fetch_assoc($res);
  5.    $num=mysql_num_rows($hasil);
  6.  
  7.     if($num!=0)
  8.  
  9.     {    
  10.     $Username="$row[nama]";
  11.     $Passwd="$row[password]";
  12.     session_register("Username","Passwd");
  13.     header ("Location: Home.php");
  14.     }
  15.     else
  16.     {
  17.         header("Location:LoginFailed.html");
  18.     }
  19.  
And everything is fine. The session is saved, because I've checked it C:\webserver\Ap ache2.2\bin\php \datasession (it is the directory where my session.save_pa th refers to.)

Then, in my Home.php I have:
Expand|Select|Wrap|Line Numbers
  1. include "ceksesi.php";
  2. // bla bla
  3.  
In ceksesi.php I have:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. if(!session_is_registered(Username) && !session_is_registered(Passwd))
  4.   {
  5.      header("location:Login.html");
  6.   }
  7. ?>   
  8.  
When Logout is pressed, the session is deleted (also, the file in ...\datasession is deleted )
Here is the code of my Logout.php :
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. session_unregister("Username");
  3. session_unregister("Passwd");
  4. session_destroy();
  5.  
The problem is, the user can open the Home.php without login. Is there any suggestion? I don't know what's wrong with my ceksesi.php.

Thanks b4...
Please....

:)
Sep 27 '07 #2
momogi
28 New Member
to all of thescripts's members...

I wanna tell you that my question is solved.
it was just a simple mistake...

--thanks--

:D
Sep 27 '07 #3

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

Similar topics

1
2887
by: lsf_80 | last post by:
I am using Session to capture my login name and this session is checking on every page that required login. However, there is a problem that the session is expired too fast! When i jump to another windows, then go back to the page that i have developed, the user is required to login again even less than 5 minutes. Thus, how can i solve this problem? This is because i can't find any problem in my code and i don't know how could this...
2
2130
by: Shashi | last post by:
My development environment is ASP.Net 1.1. When the user does multiple logins to the system and navigates to different screens and clicks back button sometimes it reading the session variables values are mixing each other. How to avoid this kind of situation? Basically I am looking for the steps to be taken when we develop web based application using ASP.Net (.Net framework 1.1) for multiple logins.
0
1365
by: DotNetShadow | last post by:
Hi Guys I was wondering if you can help me out with the following problem. I created a basic secure | non secure website. So I have the root directory as publically allowable pages and a directory called secure with one secure page in it. Hence if I access the secure.aspx page within the secure directory without being authenticaed then I'm thrown to the login page. All seems to work well, the problem I encounter is when the asp.net
3
1462
by: ywz | last post by:
Hi All, I built a web application using cookieless session. It merely checks for the session variable value upon login. This method works fine on the host pc. However, when i try to access the application via another pc in the network, the login page redirects to itself even though the correct passwd and usename is entered. I did a response.write and realise that the value of the session variable is not set. How can i solve this
0
1027
by: sasidar.d | last post by:
hi techies I have created a Login web page . It gets the user identity using the window nt authetication. The page is working fine. I have removed the allow anonymous access check box for the virtual directory and then given the check for the integrated window authetication. After deploying the project in the testing server - windows 2003 server (server called as svr10) it is working fine.
2
2065
by: Tom | last post by:
I hope someone can help me figure out what's going on here. I've re-read the section on sessions at php.net and Googled this high and low but I haven't found anything that quite explains my problem. The basic problem: session data (e.g. $_SESSION) gets dropped after visitor logs in and reloads the page via a form once or twice (it seems to vary), requiring the visitor to re-login, whereupon the problem repeats itself. An outline of...
7
3355
by: le0 | last post by:
Hello Guys, I have this problem on my page. Im doing my "Logoff" portion, everytime I click "Logoff" then click the Back button in my browser the previous page still appears. Heres my code <% If Request.QueryString("login")= "logout" Then Application.Contents.RemoveAll()
6
18228
by: somaskarthic | last post by:
Hi This is somas here. I asked query about detecting the browser close event using javascript. I want to detect the event only when the X button in the top right corner is clicked and not else where. (like moving to other pages by clicking some links). Can u help me in this case. Cause of this , In my php site, i want to restrict multiple logins with same username and password at a same time from different system. To avoid this , in...
2
4341
by: jwhite68 | last post by:
The essence of my problem is this. 1. I login to my website with user/password. 2. I select any option, which effectively re-calls index2.php with some additional parameters, to control whats displayed next. Immediately at this point, it logs out the user. It is logging out the user because after checking $_SESSION == '1' - it finds that its not 1, and therefore displays login section again and a related message. The website is being...
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10031
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
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 we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.