By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

how to Share variables among php and html

P: 3
Hi Experts,
I have created a login page in php called login.php, it accepts username, password and domain and then does some authentication. IF authentication succeeds it starts a php session and sets a session attribute. In my php application, i check this session attribute in all the pages to find out whether the user has logged in or not.

Now I have another application entirely written in html. Now I want to call this login.php page when a user tries to access any html page. Now the problem is ,I can call the login.php page using a simple javascript call but once the user enters the credentials and gets authenticated how will I pass the knowledge to the html page that the session variable is created, because if the html page does not recognize the creation of php session variable, it will again throw login.php page for users.

Please let me know how can I reuse my login.php page successfully from html pages. Please also let me know any implementation specific suggestions (like creation of a seperate login page for html application which will act like a middleware taking the session variable from php and converting it into html (session) variable or something like that, so that my html applications can use it.

May 11 '09 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 8,639
what do you consider "HTML application"? HTML is just a bunch of static mark-up, which is rendered by the browser.

on the other hand side, PHP only works on the server (and is finished before anything reaches the browser), HTML only on the client, so you just need to print out in PHP to get it in HTML (but if this can be considered secure is more than questionable).
May 11 '09 #2

P: 79
the options are..

renaming the html files to php and passing the session varilables through out the page.

other option is calling a hidden iframe which holds a php session control page [its really a dirty idea]

next option is a javascript that can communicate with php server page with ajax [this is too much complicated yet effective ]
May 18 '09 #3

P: 162

Post your reply

Sign in to post your reply or Sign up for a free account.