gingerboy101 Posted November 21, 2006 Share Posted November 21, 2006 Hi guys, Ok i have just started to write in PHP, I need a language that could talk to a data base that I could use e.g. mysql and php.Anyway, I have been adding to the old favorite of everyones, the 'member login system', I have managed to get all of the basics working, and able to allow a login, called some variables back to show how was logged in, I want to be able to allow them to update their registartion, which is on a new page called 'update_reg.php' called from a simple html <a href=".......">update</a>.But when I call the '$username' on the page 'update_reg.php' it is returned blank as are any other variables that I try, I have ensured the session_start(); is on the first (very first) line of the new page but it is not carrying the variables across.I have looked in every forum I can find and tutorial, I am sure that I just being thick but, any help please.If you nee to see any of the code then please shout.p.s. php.ini global_variables = off.Happy to learn so just point me anywhere that could help with this.Cheers Link to comment https://forums.phpfreaks.com/topic/28001-sessions-keeping-a-session-alive-iam-a-new-boy-on-the-block/ Share on other sites More sharing options...
Orio Posted November 21, 2006 Share Posted November 21, 2006 Session variables (that can be accessed after calling session_start()) are stored in the $_SESSION array. That means if you want to pass the username from page to page using the session variables, you need to store it in the array- for an example $_SESSION['user'].So, if page1.php is:[code]<?phpsession_start();$_SESSION['something']="Test123";?>[/code]And page2.php is:[code]<?phpsession_start();echo $_SESSION['something'];?>[/code]The output on page2.php will be "Test123".Hope it helps,Orio. Link to comment https://forums.phpfreaks.com/topic/28001-sessions-keeping-a-session-alive-iam-a-new-boy-on-the-block/#findComment-128099 Share on other sites More sharing options...
gingerboy101 Posted November 29, 2006 Author Share Posted November 29, 2006 Cheers Fella, Sorry been away trying to rebuld my brain....I have tried that and it seems to lose the variables, unless I switch Global_vairiables on.Is this safe?Cheers Link to comment https://forums.phpfreaks.com/topic/28001-sessions-keeping-a-session-alive-iam-a-new-boy-on-the-block/#findComment-132292 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.