 |
| Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP 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 3rd, 2004, 04:26 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Login
hi
I have member area that users have to login to access some links in my wbsite.
I'm using php 4.0 and mysql on windows Xp Home Edition
in my login.php I made script that when the users logged in I check their username and password with my mysql database and after that when the username and password was right I create session:
$_SESSION['logged'] = true;
// that login.php is included in all of my pages, something the p2p.wrox.com,it's in right of my page.
my session path is for example C:\php\session
so when i create the session i put this script in all of my pages
<?
if ($_SESSION['logged'])
echo logout;
else
echo loginform.php
it works when they logged in but when they click on the other links like click on my home page again istead of they get logout the will get again loginform.php (but they already logged in and i create session for them)
i wondering if anybody can help me.
Thanks
|
|

October 3rd, 2004, 09:28 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
maybe that would help you guys to help me
Finaly I found that i cannot carry the session to the other pages
let see
//page1.php
<? session_start(); ?>
<html>
<body>
<?php
$_session['user']= "NAME";
echo $_session['user'];
?>
<a href="page2.php">page2</a>
</body>
</html>
this page will show us the NAME
//page2.php
<? session_start(); ?>
<html>
<body>
<?php
echo $_session['user'];
?>
<a href="page2.php">page2</a>
</body>
</html>
This has to show us again NAME, but it's not
Is anybody know why?
Thanks
|
|

October 3rd, 2004, 09:57 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
I'm using php4 and mysql on windows xp home edition
in php.ini
session.save_hander = files
session.save_path = C:\WINDOWS\Temp
sesion.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = C:\WINDOWS\Temp\Coockies\
session.cookie_domain = none
session.serialize_handler = php
session.referer_check =
session.entropy_length=0
session.entropy_file =
session.cache_limiter = private
session.cache_expire = 180
session.use_trans_sid = 0
and I'm using my web in localhost (I did not put it up)
Thanks
|
|

October 4th, 2004, 04:55 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
You should probably turn up error reporting, and I believe you have to use $_SESSION and not $_session .
HTH,
-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
|
|

October 4th, 2004, 11:50 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
thanks for your repaly snib
yes i used $_SESSION but the problem is i don't know why i cannot get session on the next page?
|
|

October 5th, 2004, 12:07 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
here is another example
<?php
session_start();
$name = NAME;
$pass = PASS;
if ($username == $name && $userpass == $pass)
{
$_SESSION['login'] = true;
header ("Location: index.pnp");
}
?>
// the code above is in my login action
in index.php page
if ($_SESSION['login'])
echo logout;
else
echo login;
so as you guys know header already send me to index.php and in index.php session works. but when I click on home in my nav bar to go to index.php again, session does not work.
I hope you guys can help me
Thanks
|
|

October 7th, 2004, 10:54 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Any help for loosing the session on the next page
Thanks
|
|

October 7th, 2004, 05:26 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
In your example, where do you get $username and $password?
-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
|
|

October 26th, 2004, 11:26 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
It's from mysql table
But my problem is i do not know why i loose my session on other page, see location after login will be index.php and the login sign will change to logout, but when i click on home (address is index.php) in my navigation, the logout sign change to login sign. that means i loose my session.
i wondering is the session works on the localhost?
i put the path in c:\windows\temp, do i have to put it some where alse?
Thanks
Regards
|
|

November 9th, 2004, 05:53 PM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:if ($_SESSION['login'])
echo logout;
else
echo login;
|
you have to write session_start()before this. that mean
session_start();
if ($_SESSION['login'])
echo logout;
else
echo login;
Best Regard:
Md. Zakir Hossain (Raju)
www.rubd.net
www.xenex.rubd.net
www.forum.rubd.net
|
|
 |