Hi all!
I can't use session variables with AJAX, I can't acces them and I can't initialize the session variables. They does'nt pass via XMLHttpRequest? If I don't pass the data via AJAX, everything is OK so it's not a syntax error. Somebody else having this problem? Please help me if you know something about this, I can't find any info about this problem. Thank for help!
5 2616 acoder 16,027
Recognized Expert Moderator MVP
Welcome to TSDN!
Can you post some code here.
Hi, of course:
I have the folloving function, at authentificatio n the login.php file is requested, in that file if the user data is ok, I would like to start a session, but that event does not occur. I have all on one page, the login form is replaced by the content of the page after the authentificatio n was made.
The function which makes the request for the login.php :
function autentificare()
{
xmlHttp=GetXmlH ttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return;
}
var url="./login.php"+"?an drascache="+new Date().getTime( );
utilizator=docu ment.form.nume_ utilizator.valu e;
parola=document .form.parola.va lue;
xmlHttp.onready statechange=pro ceseazaLogarea;
xmlHttp.open("G ET",url+'&nume_ utilizator='+ut ilizator+'&paro la='+parola,tru e);
xmlHttp.send();
}
function proceseazaLogar ea()
{
if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
{
raspuns=xmlHttp .responseText;
if(raspuns=='er oare'){
document.getEle mentById('comen tariu_p').inner HTML='<b>Parola incorecta!<b>';
document.getEle mentById('comen tariu_p').class Name='erori';
}
else
{
cerereContinut( );
}
}
}
Below is the login.php content, for testing I let only
<?php
/*below the session should start, but in FireBug I can see that the session variable value is empty, as below:
Array
(
[nume_utilizator] =>
) */
session_start() ;
$utilizator=$_G ET['nume_utilizato r'];
$_SESSION['nume_utilizato r']=$_utilizator;
print_r($_SESSI ON);
echo 'ok'; //authentificatio n ok
?>
ak1dnar 1,584
Recognized Expert Top Contributor
Hi, of course:
I have the folloving function, at authentificatio n the login.php file is requested, in that file if the user data is ok, I would like to start a session, but that event does not occur. I have all on one page, the login form is replaced by the content of the page after the authentificatio n was made.
The function which makes the request for the login.php :
function autentificare()
{
xmlHttp=GetXmlH ttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return;
}
var url="./login.php"+"?an drascache="+new Date().getTime( );
utilizator=docu ment.form.nume_ utilizator.valu e;
parola=document .form.parola.va lue;
xmlHttp.onready statechange=pro ceseazaLogarea;
xmlHttp.open("G ET",url+'&nume_ utilizator='+ut ilizator+'&paro la='+parola,tru e);
xmlHttp.send();
}
function proceseazaLogar ea()
{
if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
{
raspuns=xmlHttp .responseText;
if(raspuns=='er oare'){
document.getEle mentById('comen tariu_p').inner HTML='<b>Parola incorecta!<b>';
document.getEle mentById('comen tariu_p').class Name='erori';
}
else
{
cerereContinut( );
}
}
}
Below is the login.php content, for testing I let only
<?php
/*below the session should start, but in FireBug I can see that the session variable value is empty, as below:
Array
(
[nume_utilizator] =>
) */
session_start() ;
$utilizator=$_G ET['nume_utilizato r'];
$_SESSION['nume_utilizato r']=$_utilizator;
print_r($_SESSI ON);
echo 'ok'; //authentificatio n ok
?>
-
<?php
-
session_start();
-
$utilizator=$_GET['nume_utilizator'];
-
-
# $_SESSION['nume_utilizator']=$_utilizator; # what is this underscore on $_utilizator
-
$_SESSION['nume_utilizator']=$utilizator;
-
if($_SESSION['nume_utilizator']){
-
echo 'ok';
-
}else{
-
echo 'Noap';
-
}
-
?>
-
This may help a lot for us, if you read it before your next post. Full list of Code Tag Supported Languages
Thanks
-Ajaxrand
Thank you for your reply!
Indeed, that underscore was the problem, sorry for disturbing with problems like these, I was too tired when I typed that code :) Next time I wil use the code tags round the code.
Thank you!
ak1dnar 1,584
Recognized Expert Top Contributor
Thank you for your reply!
Indeed, that underscore was the problem, sorry for disturbing with problems like these, I was too tired when I typed that code :) Next time I wil use the code tags round the code.
Thank you!
Hi andrasnet,
You are welcome anytime here @ TSDN.
Hope to c u again.
Thanks,
-Ajax rand Sign in to post your reply or Sign up for a free account.
Similar topics |
by: G Matthew J |
last post by:
interesting "signal vs. noise" blog entry:
http://37signals.com/svn/archives2/whats_wrong_with_ajax.php
|
by: peter.konda |
last post by:
Hello!
I have been busting my head with a problem, that goes like this:
1. with a first ajax call to the server(apache 2.0 + php), I create a
temporary table like this:
create temporary table peter select * from some_table limit 0,0; That
creates an empty temporary table with the same structure as some_table.
I use mysql 4.023. I use php call mysql_connect to connect to the
mysql database.
2. I create a second ajax call to the server...
|
by: mars131 |
last post by:
how can i get session with javascript only?thanks
|
by: Petra Meier |
last post by:
Hi,
on mouseclick I want to create a HTML on the server via PHP this file I
want to send to the client in a way that the user is prompted with a
"save as" dialog box.
I know how to do it "normally" (I use 'octet-stream') .. now I want to
do that with AJAX and do not succeed (the file is sent but no dialog
box).. what do I have to account for in AJAX case or is this not
possible in AJAX?
|
by: 47computers |
last post by:
I have a couple of DropDownLists in a DetailsView control (your
classic country/state lists) and I need one to be populated based on
the current selection of the other. Currently this works fine with a
postback, but an AJAX solution would be a better way of doing things.
I've been googling around for some examples and tutorials, but so far
nothing is working. I'm really a beginner with AJAX and need a simple
example or tutorial for...
| |
by: xNephilimx |
last post by:
lHi guys!
I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still lack some JavaScript solid knowdlege)
The problem is that when I try to send a form's content with Ajax (I'm using the prototype library), for some reason the latin characters (accents and stuff, like áéíóú) turn a mess when I try to store them in...
|
by: Scott M. |
last post by:
I'd like to start working with Ajax in VS 2008 Pro., but it's important that
I not use anything that is not standard with VS 2008 Pro. (with all
installation options selected).
Does anyone have suggestions of good resources I can check out that keep the
extras separate from the standard VS product?
-Scott
|
by: itpvision |
last post by:
Hello,
I have a link navigation of categories retrieved from the database,
while I know how to display subcategories based on category link
clicked with classical approach, I want to do this with ajax,
The problem is with the classical style,I know the GET sent and
the row im in with the category, so by simple comparison, I know how
to display the subcategories under its parent category, but with ajax,
I cannot know the GET and compare...
|
by: bugboy |
last post by:
I have a page being generated with PHP, it includes a DIV who's content gets swapped with ajax. the new content contains the following function call PHP echo'd inside the parent DIV.
The code works fine when originally loaded in the DIV but not when it's been swapped there with ajax.
Should i be putting the function call somewhere else in the code? The $row_num needs to reflect the row number originally clicked to call the ajax...
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
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...
|
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
| |
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...
| |