473,406 Members | 2,698 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,406 software developers and data experts.

PHP/ Ajax Login without Refresh: Help

:( ::)
Hello there,

I recently started Web Designing with PHP, Javascript and AJAX.

I am facing a problem which I will try to explain:
If I am successful in conveying the problem to you clearly, could you
pl. suggest me some solution? Thank you,
Here is the problem details:

I successfully created a Registration/Login/Logout system with CMS
features by learning through tutorials/forums like yours, using PHP/MYSQL
only. Thanks to the internet.

I want to Ajaxify the code using the Javascript programming and
XMLHttpRequest Object.

So the question I asked to myself is:
Can we login without refreshing the current page? In theory and
practice I am able to validate/check the username , password and get
back the results array from mysql without refreshing the page.

I am facing the Problems after this:
How do I retain myself in that State of LOGGEDIN situation? The answer
to this is(probably): $_SESSION variable.
But at this point I got stuck: Where should I use session_start() and
where should I assign the SESS_MEMBER_ID ? Is it in the index.php
which is the main page (which has the login screen) or is it the 'php
script' which checks for user name, password
and sends back the results. I tried adding the session code to "php
script" under the login submit button. It successfully gives me the
session id.
However, if I refresh the page, I loose that session ID:

so, my doubt is where exactly is session ID stored ? On the server or
on the client machine like a cookie.
How do we retain it ?

Its similar to when I log into yahoo / gmail account, even if I
refresh, I wont be logged out to main screen.
How is this possible without refreshing the form.

Could you pl. help on this.
Thank you very much for your time.
regards,
sincerely,
Prasad.
Feb 16 '08 #1
3 5533
acoder
16,027 Expert Mod 8TB
Hi Prasad, welcome to TSDN!

You should use sessions on the main page too, so that when the page is refreshed, you don't lose the session.
Feb 16 '08 #2
thank you @acoder.
still I am not fully clear of how to do that.
I have tried similar to your suggestion ie.

I created a main.php which has session_start(), LOGGEDIN= false;
on the main.php , there is a section called loginform, which on receiving username,
password(checks it) then regenerates session ids and then LOGGEDIN is changed
to TRUE.

Now the session should remember TRUE but if I refresh, the session information is lost, the main page come back instead of the logged in TRUE status.
Is there a place on the client computer and server, where I can look for the session id being stored and just confirm myself that it is infact storing the information and checking it during refresh.?

Ofcourse, I am using Logged in Status to hide some content which is generally visible in LOGGEDOUT status.

so, I am confused of how to do this ?
Hope you will clarify me on this ?

thank you for the earlier post and for the time too.

prasad.
Feb 17 '08 #3
acoder
16,027 Expert Mod 8TB
I haven't tested this, but when you normally start a session on a page without Ajax, you wouldn't set LOGGEDIN to false, would you? You'd check that the username is set in the session variables. The only part you need to "Ajaxify" is the login. The rest should stay the same.
Feb 18 '08 #4

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

Similar topics

5
by: Ruso | last post by:
I am using ASP to make an application. What I want right now - is to make the self updating list of the users online - based on thier cookies. In my opinion all seems to be writen well with it's...
3
by: Beshoo | last post by:
hey gaiz plz I want to cerate log in system in ajax i do it but i have one problem AFTER I start thes session then press refresh key the session gone !!! in other words , after the user type hid...
1
by: quill | last post by:
Hi I am making a chatroom script and it appears that the problem seems to be that my setTimeout's are conflicting. The logic is as follows: Run a login check every x seconds Run a trigger...
1
by: jianxin9 | last post by:
Hi, I have an ajax powered tabs box that has a javascript drop-down search menu in the first tab. When I click on another tab, and go back to the first tab I have to refresh the page to get the...
25
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e....
10
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario -------------...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
2
by: malcster2 | last post by:
hello, i am a beginner to ajax. i have created a mysql database, which i would like to access from a web page. i have created 3 files, a html to display the data, a php file to extract the data,...
6
by: KDawg44 | last post by:
Hi, My responseXML is always null on my AJAX call. When I browse directly to the PHP script I am calling, the XML file shows up just fine. I have read that if a returned XML file is not...
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
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,...
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
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,...
0
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...

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.