|
-
Oct 9th, 2005, 06:58 AM
#1
Thread Starter
Fanatic Member
couldnt retrieve cookie value!!
i have set the userID and password to cookie but when i want retrieve it, i cant get the value...why?
set cookie:
VB Code:
Session_start();
if (numRow > 0) then
$_SESSION["usr"] = username;
$_SESSION["pwd"] = pss;
'do stuff
} else{
'do stuff
}
Retrieve cookie:
VB Code:
Session_start()
$usr = $_SESSION["usr"];
$pss = $_SESSION["pwd"];
-
Oct 9th, 2005, 10:14 PM
#2
Re: couldnt retrieve cookie value!!
If you check in your cookies folder do you see the cookies you've set? Depending on your browser and/or ineternet security software settings they may be blocking your cookies from being set as well. HTH
-
Oct 10th, 2005, 11:29 AM
#3
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
still cannot retrieve value
-
Oct 10th, 2005, 06:17 PM
#4
Re: couldnt retrieve cookie value!!
Have the cookies been created if you look in your cookies folder?
-
Oct 13th, 2005, 11:34 PM
#5
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
i hv create a folder for store the cookie(all setting is done for path to save the cookies) ,but it still couldnt save the cookie in the folder
-
Oct 14th, 2005, 11:00 AM
#6
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
this is the error message after i login and set the session
VB Code:
Warning: session_start(): open(/tmp\sess_2e63865d1c9def9f28da56b3273f3476, O_RDWR) failed: No such file or directory (2) in C:\Myserver\www\adminLogin.php on line 16
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Myserver\www\adminLogin.php:16) in C:\Myserver\www\adminLogin.php on line 16
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Myserver\www\adminLogin.php:16) in C:\Myserver\www\adminLogin.php on line 16
Wrong !!b8bc49ce17ceaa21862e920068738827
Warning: Unknown(): open(/tmp\sess_2e63865d1c9def9f28da56b3273f3476, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
-
Oct 14th, 2005, 05:01 PM
#7
Re: couldnt retrieve cookie value!!
Post your code as it will help us to determine what the problem is.
-
Oct 14th, 2005, 07:42 PM
#8
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
VB Code:
<?php
$adminUserID = $_POST['txtAdminUserID'];
$adminPass = md5($_POST['txtAdminPass']);
$host ="localhost";
$dbname = "Broadcast";
$dbpass = "";
$connection = mysql_connect("$host", "$dbname");
$db = mysql_select_db("$dbname", $connection);
$results = mysql_query("select * from tblAdmin where UserID ='$adminUserID' and Password ='$adminPass'", $connection);
echo mysql_error();
session_start();
if (mysql_NumRows($results)>0){
$_SESSION["adminUID"] = $adminUserID;
$_SESSION["adminPass"] = $adminPass;
?>
<script language = "JavaScript">
document.location.href = "HomePage.htm";
</script>
<?php
} else {
echo "Wrong !!";
}
?>
-
Oct 15th, 2005, 03:24 AM
#9
Re: couldnt retrieve cookie value!!
You need to find the session.save_path setting in php.ini and set it to a valid directory otherwise PHP cannot save the session data.
-
Oct 15th, 2005, 04:14 AM
#10
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
ya...i have change the path to c:\webCookies and created a folder named "webCookies".......and display the post #6 error
-
Oct 15th, 2005, 04:19 AM
#11
Re: couldnt retrieve cookie value!!
The error in post number 6 says that the save path is "\tmp" are you sure that the script is using that php.ini file?
Call phpinfo(); to check that it can find php.ini too.
-
Oct 15th, 2005, 06:57 AM
#12
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
hmmmm.....same problem!! i alr check the session_savepath is set to c:\webCookies
-
Oct 15th, 2005, 07:34 AM
#13
Re: couldnt retrieve cookie value!!
phpinfo() will tell you which php.ini file is being used, if any.
-
Oct 15th, 2005, 08:12 AM
#14
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
-
Oct 15th, 2005, 01:40 PM
#15
Re: couldnt retrieve cookie value!!
-
Oct 15th, 2005, 10:03 PM
#16
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
it locate in C:\WINDOWS\php.ini .........what i need to do? change the save.path to this or .........??
-
Oct 16th, 2005, 02:13 AM
#17
Re: couldnt retrieve cookie value!!
Well where is the php.ini you are editing? If it you have not already copy it into C:\windows
-
Oct 16th, 2005, 08:01 AM
#18
Thread Starter
Fanatic Member
Re: couldnt retrieve cookie value!!
i edit the php.ini in php inside php folder..........what not really understand what u mean?
-
Oct 16th, 2005, 09:32 AM
#19
Fanatic Member
Re: couldnt retrieve cookie value!!
First thing, that's not cookies, that are sessions.
<?php
session_start();
session_register("yourVar");
$_SESSION["yourVar"] = $_POST["txtAdminUserID"];
when you use $_POST['txtAdminUserID'] if the value of txtAdminUserID has spaces it will just read the first part untill the space and the rest of the value will be ignored.
Second: cookies:
#########-----> Set cookie
http/1.0 200
Content-Length: 1276
Content-Type: TEXT/HTML
Date: True, 06 Nov 2001 04:12:49 GMT
Expires: True, 06 Nov 2001 04:12:59 GMT
Server: simwebs/3.1.6
Set-Cokie: animal=egg-laying-mammal
It's donne like:
<?php
setcookie("vegetal", "rice", time() + 3600, "/", "localhost", 0);
if (isset($_COOKIE["vegetal"])) {print $_COOKIE["vegetal"];}
?>
3rd:
Be sure that exist:
C:\Myserver\www\tmp
or C:\tmp
4th:
$results = mysql_query("select * from tblAdmin where UserID ='$adminUserID' and Password ='$adminPass'", $connection);
That's wrong!
String are compared using LIKE
$results = mysql_query("SELECT * FROM `tblAdmin` WHERE UserID LIKE \"$adminUserID\" and Password LIKE \"$adminPass\"", $connection);
Last edited by TDQWERTY; Oct 16th, 2005 at 09:37 AM.
-
Oct 16th, 2005, 11:01 AM
#20
Re: couldnt retrieve cookie value!!
 Originally Posted by kenny_oh
i edit the php.ini in php inside php folder..........what not really understand what u mean?
copy C:\php\php.ini to C:\windows\php.ini then your problem will be solved
-
Oct 20th, 2005, 03:06 AM
#21
Member
Re: couldnt retrieve cookie value!!
Is 'session_register("yourVar");' necessary? I've just posted a thread with a similar problem, except the $_SESSION variables are set but can only be retrieved from one page.
Also Kenny_Oh, it might be wise to validate the data the user puts in the form, bearing in mind your code is open to SQL injection attacks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|