Member Panel


Sponsors and Ads

Live Tag Cloud

PC Forum PC Help Forum » Web & Networking » Web Design » [PHP] Sessions not working

Web Design - [PHP] Sessions not working posted in the Web & Networking forums; Let's try a little bit of troubleshooting here... At the beginning of the second function (the login checking one), insert the following code: Code: //Let's see if the session vars ...

JOIN US NOW to remove these Ads

Post New Thread  Reply
  #7  
Old 02-28-2006
Spaceman3750's Avatar
Elite Member
My PC
 
Join Date: Jan 2004
Location: Riverton, IL, USA
Posts: 1,511
PC Experience: Very Experienced
Spaceman3750 - See this Members User comments on their Profile page
Send a message via AIM to Spaceman3750 Send a message via MSN to Spaceman3750 Send a message via Yahoo to Spaceman3750
Default

Let's try a little bit of troubleshooting here...

At the beginning of the second function (the login checking one), insert the following code:

Code:
//Let's see if the session vars were stored
echo "Name: $_SESSION[name], Pass: $_SESSION[pass]";
exit();
Note that the script will stop execution at exit(), I just want to know if the session vars were recorded and sent properly.


__________________
- Ryan
http://www.spaceman3750.info
http://www.conglomerate-game.net

Cisco Academy - CCNA student
  #8  
Old 02-28-2006
Ge64's Avatar
P C H F R 0 0 l Z
 
Join Date: Oct 2005
Location: Hong Kong
Posts: 232
PC Experience: Good at least
Ge64 - See this Members User comments on their Profile page
Send a message via MSN to Ge64
Default

Originally Posted by Spaceman3750
Let's try a little bit of troubleshooting here...

At the beginning of the second function (the login checking one), insert the following code:

Code:
//Let's see if the session vars were stored
echo "Name: $_SESSION[name], Pass: $_SESSION[pass]";
exit();
Note that the script will stop execution at exit(), I just want to know if the session vars were recorded and sent properly.
Did that, first it gave me

Notice: Undefined index: name in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 17

Notice: Undefined index: pass in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 17
Name: , Pass:

but then I noticed it should be:

Code:
//Let's see if the session vars were stored
echo "Name: $_SESSION['name'], Pass: $_SESSION['pass']";
exit();
But then it gives me

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 17

So I make it

Code:
//Let's see if the session vars were stored
echo "Name: " . $_SESSION['name'] . ", Pass: " . $_SESSION['pass'];
exit();
But then it does


Notice: Undefined index: name in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 17

Notice: Undefined index: pass in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 17
Name: , Pass:

again :S


__________________
PCHF RoX ur SoX
:computer1
PC SmAsH0R
  #9  
Old 02-28-2006
Spaceman3750's Avatar
Elite Member
My PC
 
Join Date: Jan 2004
Location: Riverton, IL, USA
Posts: 1,511
PC Experience: Very Experienced
Spaceman3750 - See this Members User comments on their Profile page
Send a message via AIM to Spaceman3750 Send a message via MSN to Spaceman3750 Send a message via Yahoo to Spaceman3750
Default

My guess would have to be that the session vars aren't being stored or retrieved correctly. Try placing session_start(); at the beginning of the second function and trying again.


__________________
- Ryan
http://www.spaceman3750.info
http://www.conglomerate-game.net

Cisco Academy - CCNA student
  #10  
Old 02-28-2006
Ge64's Avatar
P C H F R 0 0 l Z
 
Join Date: Oct 2005
Location: Hong Kong
Posts: 232
PC Experience: Good at least
Ge64 - See this Members User comments on their Profile page
Send a message via MSN to Ge64
Default

Originally Posted by Spaceman3750
My guess would have to be that the session vars aren't being stored or retrieved correctly. Try placing session_start(); at the beginning of the second function and trying again.
Notice: A session had already been started - ignoring session_start() in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 16

Notice: Undefined index: name in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 19

Notice: Undefined index: pass in /sites/herejezus-sites/www.ge64.nl/alpha/func.php on line 19
Name: , Pass:


__________________
PCHF RoX ur SoX
:computer1
PC SmAsH0R
  #11  
Old 02-28-2006
Ge64's Avatar
P C H F R 0 0 l Z
 
Join Date: Oct 2005
Location: Hong Kong
Posts: 232
PC Experience: Good at least
Ge64 - See this Members User comments on their Profile page
Send a message via MSN to Ge64
Default

W0000T i figured it out

I changed:

Code:
$sname = $login['name'];
session_register("sname");
$spass = $login['pass'];
session_register("spass");
//$_SESSION['name'] = $login['name'];
//$_SESSION['pass'] = $login['pass'];
into

Code:
//$sname = $login['name'];
//session_register("sname");
//$spass = $login['pass'];
//session_register("spass");
$_SESSION['name'] = $name;
$_SESSION['pass'] = $pass;
where $name and $pass should be the same as $long['name'] and $login['pass'].

Thanks for helping and pointing me the right way again


__________________
PCHF RoX ur SoX
:computer1
PC SmAsH0R
  #12  
Old 02-28-2006
Ge64's Avatar
P C H F R 0 0 l Z
 
Join Date: Oct 2005
Location: Hong Kong
Posts: 232
PC Experience: Good at least
Ge64 - See this Members User comments on their Profile page
Send a message via MSN to Ge64
Default

Still something is wrong, lets see if I can fix that ...


__________________
PCHF RoX ur SoX
:computer1
PC SmAsH0R

Reply
New! Norton Internet Security 2008 – Download Now Click Here

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


All times are GMT +1. The time now is 05:51 AM.
Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC7
All Graphics & Content Copyright © 2004-2008 - PC Help Forum.com


Back to Top