Session variables set on the homepage... how to redirect or generate values?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pezholio
    New Member
    • Jun 2007
    • 22

    Session variables set on the homepage... how to redirect or generate values?

    Hi,

    Long time reader, first time poster here. Hi!

    I've got a problem regarding an eLearning system I'm trying to get people to use. The actual system itself is horrible, so I've recreated the course info on our own website. After choosing the course they want, the user then can sign up and pay. Once payment has been received, the course is activated manually by a member of staff clicking a link and the user is emailed with a link to the course on the eLearning system.

    This is where I have problems.

    The system is session-based and if a user clicks on the link without first visiting the homepage of the system, they're confronted with a blank page.

    I'd therefore like a way of redirecting the user to the homepage (to pick up the session variables) and then redirecting them to the relevant course, is this possible? As I'm an accessibility nut, I'd really like to avoid any client-side stuff.

    Cheers :)
  • merseyside
    New Member
    • Mar 2007
    • 48

    #2
    How is the user associated with the server session, cookie or URL? Assuming a login is required, what happens when a user tries to access a page that requires a valid login? Are they redirected to the homepage or a login page?

    Comment

    • Purple
      Recognized Expert Contributor
      • May 2007
      • 404

      #3
      Hi pezholio and welcome to TSDN !!,

      Strip the code from the homepage which is setting up the session variables and put it into a function.

      Check on every page the session variables exist and are set correctly and if they don't run the function to create them - you could also include a test to confirm they have logged on correctly and kick them out if not..

      Purple
      Last edited by Purple; Jun 15 '07, 11:50 AM. Reason: .

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Changed thread title to better describe the problem.

        Comment

        • Motoma
          Recognized Expert Specialist
          • Jan 2007
          • 3236

          #5
          Originally posted by pezholio
          Hi,

          Long time reader, first time poster here. Hi!

          I've got a problem regarding an eLearning system I'm trying to get people to use. The actual system itself is horrible, so I've recreated the course info on our own website. After choosing the course they want, the user then can sign up and pay. Once payment has been received, the course is activated manually by a member of staff clicking a link and the user is emailed with a link to the course on the eLearning system.

          This is where I have problems.

          The system is session-based and if a user clicks on the link without first visiting the homepage of the system, they're confronted with a blank page.

          I'd therefore like a way of redirecting the user to the homepage (to pick up the session variables) and then redirecting them to the relevant course, is this possible? As I'm an accessibility nut, I'd really like to avoid any client-side stuff.

          Cheers :)
          When your page detects that the SESSION is not properly set, store the current URL in the SESSION, and use a header("Locatio n: ...") call to send the user back to the login page. Your after authenticating, your auth script will check the SESSION for the redirect, and if it is there, use the header("Locatio n : ...") call again.

          Comment

          Working...