smc Posted January 21, 2007 Share Posted January 21, 2007 Hello,I have googled and checked the manual but I just can't find anything I understand that relates to what I'm doing.Basically I have my login script. They login and it starts a session. Here is my session code:[code=php:0]else{//We will now start our sessionsession_start();//Now we are going to assign all that information we retrieved from our database to our session so it can be used later$_SESSION['username'] = $sqlusername;$_SESSION['password'] = $sqlpassword;$_SESSION['firstname'] = $sqlfirstname;$_SESSION['lastname'] = $sqllastname;$_SESSION['position'] = $sqlposition;$_SESSION['rank'] = $sqlrank;$_SESSION['email'] = $sqlemail;[/code]Now it works when the page reloads and displays the session username in a string. But my problem lies when trying to go to a different page.I placed a link to an "admin panel" on the login success page. This admin panel page checks the SESSION 'rank' and sees if it matches "admin" if it doesn't it shows an error page.I just keep getting the error page, which leads me to believe the session is broken after the link is visited (link opens in same window).How do I go about continuing the session until the browser closes or they click a button that does a session_destroy(); function?Thanks!!! Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 You don't, that's the point of sessions. You'd have to move the info into cookies.Edit: well maybe not the point, but how they work. Sessions last only for the browser session - session meaning period of use. If you close the browser or kill the session, it's gone. Quote Link to comment Share on other sites More sharing options...
smc Posted January 21, 2007 Author Share Posted January 21, 2007 Thats what I mean. I'm talking about not carrying data from one browser session to the next, but from one page to the next.I [b]want[/b] the session to end when the browser is terminiated Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 Ah, I read too quickly. You need to have session_start() on every page.Plus, they don't go from subdomains. The session on www.site.com is not the same as site.com or admin.site.com. Quote Link to comment Share on other sites More sharing options...
smc Posted January 21, 2007 Author Share Posted January 21, 2007 That shouldn't be a problem as long as it can do site.com and site.com/directoryLet me try the session deal Quote Link to comment Share on other sites More sharing options...
smc Posted January 21, 2007 Author Share Posted January 21, 2007 Yup that did it, thanks :) :) Quote Link to comment 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.