d22552000 Posted September 3, 2007 Share Posted September 3, 2007 ok so my first time ever trying to use sessions... and I suck at it. Normally I simply don't use sessions altogether. So bear with me. session_start(); session_register($id); header("location: index.php?id=".$id."&pw=".$pw."&s=2"); This happens to set the session IF you get your password right. Do I need to pass a sid or semething to the page for it to get it? I have set the script to generate a 403 error if the session is either invalid or not set. I goto the page and I get a 403. How do I set sessions then? if (isset($_SESSION['$id'])) { That is what checks for the session.. am I doing this all wrong? Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/ Share on other sites More sharing options...
trq Posted September 3, 2007 Share Posted September 3, 2007 session_register() has long been depricated. Try this example. p1.php <?php session_start(); $_SESSION['foo'] = 'hello'; echo "<a href='p2.php'>p2</a>"; ?> p2.php <?php session_start(); if (isset($_SESSION['foo'])) { echo $_SESSION['foo']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340474 Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 why would I put session start on the second page? Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340476 Share on other sites More sharing options...
trq Posted September 3, 2007 Share Posted September 3, 2007 Becasue it needs to be called on all pages you wish to use sessions on. Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340478 Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 the funny part is this is all one page... but ok if (isset($_SESSION['$id']) && ($_SESSION['$id'] == $pw)) { would that be a better session checker? and I changed my set code to: session_start(); $_SESSION['$id'] = $p I might as well put session_start(); at the top of hte page since the whole page is a restartcted area and it has its own login system, all in one php ifle Why would I not put session_start at the top of the page? Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340481 Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 nope still my anti-hacking system is htinking im hacking. ***HIDDEN*** Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340483 Share on other sites More sharing options...
trq Posted September 3, 2007 Share Posted September 3, 2007 You need to use $_SESSION['id'] not $_SESSION['$id']. Its just like any other array. Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340485 Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 ***FIXED*** THanks for your help Thore... I see you like Stargate-SG1? Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340487 Share on other sites More sharing options...
trq Posted September 3, 2007 Share Posted September 3, 2007 I see you like Stargate-SG1 Not likely... What gives you that impression? Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340493 Share on other sites More sharing options...
Azu Posted September 3, 2007 Share Posted September 3, 2007 I see you like Stargate-SG1 Not likely... [insert angry face here] Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340567 Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 I love stargate-sg1 ;D ;D GRIN SPAM Quote Link to comment https://forums.phpfreaks.com/topic/67776-solved-uh-sessions-i-suck-at-them/#findComment-340569 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.