Session Question
Posted: Wed Nov 07, 2007 3:37 pm
We are developing a site for a client in which they have a members only section. Upon logging into the members section, the left navigation on the site is updated to add the members nav elements to it. I can handle the login fine and the navigation between members pages is fine but when the user navigates to a page that is a public page, the member nav disappears.
Obviously I'm not carrying the session variables across pages but I'm not sure how to solve this.
When a user logs into the members section, I'm using the following code to register the session:
The $userid value is pulled from the database which matches the users login credentials (username/password).
What do I need to do on the public pages to check for the session? I thought I just needed to use some code like this:
If I'm not mistaken, doesn't this code check to see if the session exists and then if so, do the actions following, which in this case would be to display the member nav. Is there something I need to do before this to carry the session variables across pages?
Obviously I'm not carrying the session variables across pages but I'm not sure how to solve this.
When a user logs into the members section, I'm using the following code to register the session:
Code: Select all
session_name('sn_user2'); session_register('sn_user2'); $_SESSION['sn_user2'] = $userid;What do I need to do on the public pages to check for the session? I thought I just needed to use some code like this:
Code: Select all
if (isset($_SESSION['sn_user2'])) {