 |
| MySQL General discussion about the MySQL database. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 23rd, 2004, 01:09 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Session Error in PHP
I have a problem with my session in PHP with code like these :
cek_login.php
<?
session_start();
session_register("username");
if ((!$username) or (!$pass))
{
echo "Login tidak lengkap ";
}
else
{
$koneksi = mysql_connect("localhost", "", "") or die (mysql_error());
mysql_select_db("latihan_php");
$passwd = md5($pass);
$query_login = mysql_query("select count(*) as login from anggota where username= '$username' and pass = '$passwd'") or die (mysql_error());
$row = mysql_fetch_array($query_login);
if ($row["login"] == "1")
{
session_register("username");
header("location:member.php");
}
else
{
header("location:non_member.php");
}
}
?>
When I login form login.html and click submit button there are error messages like these :
Warning: Cannot send session cookie - headers already sent by (output started at C:\apache\htdocs\latihan_session\cek_login.php:12) in C:\apache\htdocs\latihan_session\cek_login.php on line 13
Warning: Cannot send session cache limiter - headers already sent (output started at C:\apache\htdocs\latihan_session\cek_login.php:12) in C:\apache\htdocs\latihan_session\cek_login.php on line 13
Warning: open(/tmp\sess_c3b315c71b5b79f890ef0f993ee3073a, O_RDWR) failed: m (2) in C:\apache\htdocs\latihan_session\cek_login.php on line 13
Login tidak lengkap
Warning: open(/tmp\sess_c3b315c71b5b79f890ef0f993ee3073a, O_RDWR) failed: m (2) in Unknown on line 0
Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
Some one help me, please !!!!
Best regard,
Randhy
|
|

October 24th, 2004, 08:49 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Are there any lines left above the code that you posted here? If so, move the session_start(); to the top of this page. This should be the first line of code on your page.
Try this simple example.
Code:
<?
session_start();
$_SESSION['abc'] = "hello world";?>
<html>
<head>
<title>test session</title>
</head>
<body>
<? echo "The content of sess variable is $_SESSION['abc']";?>
</body>
</html>
Try to play around with this by adding some lines on top of this page and see how that behaves.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

October 26th, 2004, 06:15 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have tried you code and there are some error messagees again :
Warning: open(/tmp\sess_607eafeccb9a366192f599262a6d3039, O_RDWR) failed: m (2) in C:\apache\htdocs\latihan_session\lat01.php on line 2
The content of sess variable is hello world
Warning: open(/tmp\sess_607eafeccb9a366192f599262a6d3039, O_RDWR) failed: m (2) in Unknown on line 0
Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
Best Regards,
Randhy
|
|

October 26th, 2004, 06:20 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
What is the OS that you use? Unix/linux/Windows?
_________________________
- Vijay G
Strive for Perfection
|
|

October 26th, 2004, 06:26 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Windows XP Professional edition.
|
|

October 26th, 2004, 06:47 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Okay, look for php.ini under PHP installed folder, and that should be having session.save_path that defaults to the UNIX '/tmp' folder, which you got to uncomment(if commented) and change it to point to Windows TEMP folder.
That should solve this problem.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

October 29th, 2004, 06:47 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have replaced the value of session.save_path to be : C:\Documents and Settings\mahasiswa\Local Settings\Temporary Internet Files, but the cookie is still have errors.
Warning: Cannot send session cookie - headers already sent by (output started at C:\apache\htdocs\latihan_session\cek_login.php:12) in C:\apache\htdocs\latihan_session\cek_login.php on line 13
Warning: Cannot send session cache limiter - headers already sent (output started at C:\apache\htdocs\latihan_session\cek_login.php:12) in C:\apache\htdocs\latihan_session\cek_login.php on line 13
Best reagrds,
Randhy
|
|

October 30th, 2004, 01:01 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
So you are out of that error now.
setcookie() defines a cookie to be sent along with the rest of the
header information. Cookies must be sent before any other headers are
sent (this is a restriction of cookies, not PHP). This requires you to place calls to this function before any <html> or <head> tags.
And see to that you don't leave unnecessary extra carriage returns at the top.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

December 17th, 2004, 07:49 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
<html>
<Head> An online Banking System</Head>
<br />
<b>Warning</b>: session_start(): open(/tmp\sess_d27d55cebff708ee57c525dab324332b, O_RDWR) failed: No such file or directory (2) in <b>C:\apache\htdocs\beebaho\devSite\userLogin1.php </b> on line <b>6</b><br />
<br />
<b>Warning</b>: session_start(): Cannot send session cookie - headers already sent by (output started at C:\apache\htdocs\beebaho\devSite\userLogin1.php:3) in <b>C:\apache\htdocs\beebaho\devSite\userLogin1.php </b> on line <b>6</b><br />
<br />
<b>Warning</b>: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\apache\htdocs\beebaho\devSite\userLogin1.php:3) in <b>C:\apache\htdocs\beebaho\devSite\userLogin1.php </b> on line <b>6</b><br
same prob any solution
The impossible does not exist
|
|
 |