[PHP] Re: Help with example session class (second request)
Not quite sure where you got this $login class instance from, but it appears to be from thin air. If you have a session class then you would need to instantiate it first with: $login = new XYZSessionClass(); // plus any constructor arguments However, I am a bit confused as you mention using PHP session management - this doesn't require any objects at all, and definately doesn't invlove a getSessionVar() method. To register a session var, use: session_register (var_name); And then you just simply use it as you would any normal variable on other pages. regards, Mikey Daevid Vincent [EMAIL PROTECTED] wrote in message 001801c2080d$b67c4630$45193e04@telecom">news:001801c2080d$b67c4630$45193e04@telecom... Sorry for posting this again so soon, but until I get sessions working, I'm blocked on this project. D. --- I'm just learning sessions, and thought the class looked interesting on this page: http://www.php.net/manual/en/ref.session.php So I have this on an index.phtml page and I can see the variables are being set and all looks good there, however upon successful login I wish to redirect to content.phtml At the very top of content.phtml I have: ?php if( $login-getSessionVar(login) ) { $booth_id = $login-getSessionVar(booth_id); $booth_name = $login-getSessionVar(booth_name); echo \nBRbooth_id = $booth_id and booth_name = $booth_nameBR\n; } else { Header(Location: ../index.phtml\n\n); exit; } ? But it doesn't seem that $login exists or is defined now on this page? So my question is basically, how can I use the class and the session variables across multiple pages? Do I need to move the class to an include file? Do I need to re-create it on each page somehow? Can someone show me a real working example of this scenario? Daevid Vincent http://daevid.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with example session class (second request)
Oops - should have read down a lot further... Michael Davey [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Not quite sure where you got this $login class instance from, but it appears to be from thin air. If you have a session class then you would need to instantiate it first with: $login = new XYZSessionClass(); // plus any constructor arguments However, I am a bit confused as you mention using PHP session management - this doesn't require any objects at all, and definately doesn't invlove a getSessionVar() method. To register a session var, use: session_register (var_name); And then you just simply use it as you would any normal variable on other pages. regards, Mikey Daevid Vincent [EMAIL PROTECTED] wrote in message 001801c2080d$b67c4630$45193e04@telecom">news:001801c2080d$b67c4630$45193e04@telecom... Sorry for posting this again so soon, but until I get sessions working, I'm blocked on this project. D. --- I'm just learning sessions, and thought the class looked interesting on this page: http://www.php.net/manual/en/ref.session.php So I have this on an index.phtml page and I can see the variables are being set and all looks good there, however upon successful login I wish to redirect to content.phtml At the very top of content.phtml I have: ?php if( $login-getSessionVar(login) ) { $booth_id = $login-getSessionVar(booth_id); $booth_name = $login-getSessionVar(booth_name); echo \nBRbooth_id = $booth_id and booth_name = $booth_nameBR\n; } else { Header(Location: ../index.phtml\n\n); exit; } ? But it doesn't seem that $login exists or is defined now on this page? So my question is basically, how can I use the class and the session variables across multiple pages? Do I need to move the class to an include file? Do I need to re-create it on each page somehow? Can someone show me a real working example of this scenario? Daevid Vincent http://daevid.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php