0

I am facing a bit of a challenging problem:

Our website has a home page, which has no uri parameters, and is just the domain name. When a user logs in, I also want to use the home page (no uri) for their login home page.

This would usually be fine with PHP because it would be a matter of checking the session – if they aren't logged in, show the public home page, else show the logged in home page. But, I want to use angular for the logged in part of the site.

Is there a way I can use the domain without any uri params for angular when the user is logged in, and for then the user isn't logged in?

I was thinking this COULD be a solution, to use

http://www.theawesomesite.org.au/home (now public home)

instead of

http://www.theawesomesite.org.au (now logged in home)

for the public home page, but then I would somehow have to redirect searches that come from google pages of users expecting to see the home page?

laser
  • 1,388
  • 13
  • 14
Sneaksta
  • 1,041
  • 4
  • 24
  • 46

1 Answers1

0

From your initial PHP script, check the $_SESSION variable that tracks whether the user is logged in. Then send the relevant page with readfile();

<?php
  if (isset($_SESSION['logged_in'])) {
    readfile("myLoggedInPage.html");
  } else {
    readfile("myNotLoggedInPage.html");
  }

If you need PHP functionality, use include() instead of readfile()

  • Is php able to read cookies that are set by angular? If not then this won't work, as I am setting the logged in state through angular. – Sneaksta Jul 17 '13 at 01:17
  • 1
    Provided you're on the same domain for everything you should be able to read/write the cookies from PHP and Angular. Be careful with the cookie path. See [this question](http://stackoverflow.com/questions/14196229/cant-delete-cookie-with-angularjss-cookies) –  Jul 17 '13 at 01:30