jstlouis Posted February 24, 2010 Share Posted February 24, 2010 Hi, I have a quick question, however I'm not sure if this can be done or not. I'm new to PHP, and haven't been able to find the answer I'm looking for via "google" searches. I have two websites, one written in JSP and the new one being written in PHP. Is there a way I can "redirect" and "login" an authenticated user from my PHP site to my JSP site, using $_POST, "fsocketopen" or another way possibly? I would store the login credentials (user/pass) from the JSP site in a MySQL database and linked to user's PHP credentials. I found quite a few articles on "retrieving" information from another Website, but haven't found any specific information on "redirecting with login" to another site. Any assistance, pointers or good articles on this topic would be very much appreciated. I need a little nudge in the right direction. Thanks Link to comment https://forums.phpfreaks.com/topic/193205-redirect-and-login-to-another-website-with-php/ Share on other sites More sharing options...
teamatomic Posted February 24, 2010 Share Posted February 24, 2010 method #1 On site one: set a cookie with the domain for site one with the login details on site two: check for that cookie and use it if it exists. *note: this only works if the client allows a domain to set a cookie for a domain other than itself. method #2 if the domains are on the same server you can set the session file location to a common location and pass the session ID via GET or POST HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193205-redirect-and-login-to-another-website-with-php/#findComment-1017396 Share on other sites More sharing options...
jstlouis Posted March 2, 2010 Author Share Posted March 2, 2010 I'm still having some troubles with getting this to work... I don't really want to start modifying the CODE on the JSP pages, as my experience here is even more limited that PHP. What about using "fsockopen" OR "curl" to do the job? Can I post the login data using CURL from my PHP Code to the JSP Page being served by a Glassfish Server? I've found quite a few articles explaining how to POST and RETRIEVE data from another site, but NOT actually redirecting after credentials are supplied... When the page comes back, it has my "localhost" URL, so I cannot navigate or use the page... (Still having some troubles posting the data though, as it keeps showing me my login page for the JSP site with the mangled URL... Could I somehow use "pregmatch" to modify the returned CURL URL from localhost (my server) to the IP Address/PORT# of the JSP Server? I'm having troubles figuring out how to do this, if it's even possible... If so, how do I access the returned URL from CURL? Thanks in advance for any assistance... Link to comment https://forums.phpfreaks.com/topic/193205-redirect-and-login-to-another-website-with-php/#findComment-1020496 Share on other sites More sharing options...
inversesoft123 Posted March 2, 2010 Share Posted March 2, 2010 Redirecting users to another site with login information when site is hosted on remote server (not tried yet :-p) is a security risk. Link to comment https://forums.phpfreaks.com/topic/193205-redirect-and-login-to-another-website-with-php/#findComment-1020531 Share on other sites More sharing options...
jstlouis Posted March 2, 2010 Author Share Posted March 2, 2010 Actually, both sites are hosted on the same server... The JSP site is hosted by the Glassfish Application Server and the PHP site is currently being server by Apache (and eventually the Zend Application Server once I'm comfortable with it). The underlying Server OS is CentOS 5.3/5.4 (completely patched and updated). So the information really isn't being sent over the internet to an another server, which hopefully should remove any security risks... ************************************ What about posting a hidden form ************************************ Is it possible to embed a "hidden" html form into my PHP page and then use the JSP page to authenticate the information? Just submit the form to the JSP page? Thanks, Link to comment https://forums.phpfreaks.com/topic/193205-redirect-and-login-to-another-website-with-php/#findComment-1020551 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.