Removing composer.lock
[phpmyadmin.git] / examples / signon.php
blob9b64326f5c58a604856680c222cdb4c604e3aa6c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Single signon for phpMyAdmin
6 * This is just example how to use session based single signon with
7 * phpMyAdmin, it is not intended to be perfect code and look, only
8 * shows how you can integrate this functionality in your application.
10 * @package PhpMyAdmin
11 * @subpackage Example
14 /* Use cookies for session */
15 ini_set('session.use_cookies', 'true');
16 /* Change this to true if using phpMyAdmin over https */
17 $secure_cookie = false;
18 /* Need to have cookie visible from parent directory */
19 session_set_cookie_params(0, '/', '', $secure_cookie, true);
20 /* Create signon session */
21 $session_name = 'SignonSession';
22 session_name($session_name);
23 // Uncomment and change the following line to match your $cfg['SessionSavePath']
24 //session_save_path('/foobar');
25 @session_start();
27 /* Was data posted? */
28 if (isset($_POST['user'])) {
29 /* Store there credentials */
30 $_SESSION['PMA_single_signon_user'] = $_POST['user'];
31 $_SESSION['PMA_single_signon_password'] = $_POST['password'];
32 $_SESSION['PMA_single_signon_host'] = $_POST['host'];
33 $_SESSION['PMA_single_signon_port'] = $_POST['port'];
34 /* Update another field of server configuration */
35 $_SESSION['PMA_single_signon_cfgupdate'] = array('verbose' => 'Signon test');
36 $id = session_id();
37 /* Close that session */
38 @session_write_close();
39 /* Redirect to phpMyAdmin (should use absolute URL here!) */
40 header('Location: ../index.php');
41 } else {
42 /* Show simple form */
43 header('Content-Type: text/html; charset=utf-8');
44 echo '<?xml version="1.0" encoding="utf-8"?>' , "\n";
46 <!DOCTYPE HTML>
47 <html lang="en" dir="ltr">
48 <head>
49 <link rel="icon" href="../favicon.ico" type="image/x-icon" />
50 <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
51 <meta charset="utf-8" />
52 <title>phpMyAdmin single signon example</title>
53 </head>
54 <body>
55 <?php
56 if (isset($_SESSION['PMA_single_signon_error_message'])) {
57 echo '<p class="error">';
58 echo $_SESSION['PMA_single_signon_error_message'];
59 echo '</p>';
62 <form action="signon.php" method="post">
63 Username: <input type="text" name="user" /><br />
64 Password: <input type="password" name="password" /><br />
65 Host: (will use the one from config.inc.php by default)
66 <input type="text" name="host" /><br />
67 Port: (will use the one from config.inc.php by default)
68 <input type="text" name="port" /><br />
69 <input type="submit" />
70 </form>
71 </body>
72 </html>
73 <?php