diode Posted January 8, 2007 Share Posted January 8, 2007 Hello,How should I pass the value of the status of the user's account that is signed in (integer), the account number of the logged in account (integer), and a couple other integer variables if I don't want them to be able to see that they are being passed from page to page? I don't want them in the url. How do most messageboards keep track of information on logged-in sessions such as these, so it will say Welcome <acctname>? Or keep track of the theme of the page layout, order of messages that appear on the page, etc.?And if you suggest cookies, can you please give an example of how it's done...you should know that I have spent hours studying the php manual's examples on registering session variables or something, and I'm still confused, it's not working. And just so you know:PHP Version 4.4.1Darwin PowerMac-G4.local 8.8.0 Darwin Kernel Version 8.8.0: Fri Sep 8 17:18:57 PDT 2006; root:xnu-792.12.6.obj~1/RELEASE_PPC Power MacintoshThanks in advance! :)diode Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/ Share on other sites More sharing options...
fert Posted January 8, 2007 Share Posted January 8, 2007 Use sessionsput[code]session_start();[/code]at the top of your page(s) Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155558 Share on other sites More sharing options...
diode Posted January 8, 2007 Author Share Posted January 8, 2007 That will do nothing to pass values from page to page...and I forgot to say that I have that line there.Thanks, :)diode Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155568 Share on other sites More sharing options...
fert Posted January 8, 2007 Share Posted January 8, 2007 page1.php[code]<?phpsession_start();$_SESSION['value']="foo";header("Location: page2.php");?>[/code]page2.php[code]<?phpsession_start();echo $_SESSION['value'];?>[/code] Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155572 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Share Posted January 8, 2007 ok, you could use the $_POSt array to send the data, but that would mea that you would have to have a form. you could have the form fields hidden, and have the submit buttom a link, thats activated using javascript.you could use cookies, or sessions, cookies ( after which creating them, you would either use header(); or just use a link that the user clicks):createcookie('cookie name', 'cokkie value', 'cokkie expiration time (ie date(d,m,Y h-i-S);)'); ( i thinkl thats the right toime format???)to create a session value:$_SESSION['Name'] = 'Value';easy as that Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155574 Share on other sites More sharing options...
magic2goodil Posted January 8, 2007 Share Posted January 8, 2007 Never store sensative info in a cookie unless it is encrypted...hell i even encrypt sensative session vars. Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155600 Share on other sites More sharing options...
diode Posted January 8, 2007 Author Share Posted January 8, 2007 If the session_start() function must be located near the top of the code, then when a user goes to the login page, the page would automatically start the session even if he/she entered invalid log-in information. I was going to do a conditional if statement and start the session if the user entered correct and valid log-in information, but alas, this cannot be done because it must be near the top of the page. So my question to you is this, how would you prevent a user from logging in, or starting a session, whichever it technically is, if he/she enters invalid log-in information?Thanks :),diode Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155619 Share on other sites More sharing options...
magic2goodil Posted January 8, 2007 Share Posted January 8, 2007 starting a session does not matter really..anyone can start a session without u having problems..the only thing that matters is what you store in the session after it has been started.. Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155629 Share on other sites More sharing options...
diode Posted January 8, 2007 Author Share Posted January 8, 2007 Ok I think I get it now. damn it's late. I'll have to try it tomorrow, er, later on today. Thanks :),diode Link to comment https://forums.phpfreaks.com/topic/33300-how-should-i-pass-these-variables-from-page-to-page/#findComment-155638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.