Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit']))
- {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $expiry = new Datetime('+1 year');
- setcookie('username', $username, $expiry->getTimestamp());
- setcookie('password', $password, $expiry->getTimestamp());
- echo $_COOKIE['username'].", ".$_COOKIE['password'];
- }
- ?>
- <form action="#" method="post">
- <label for="username">Username: </label><input type="text" name="username"><br />
- <label for="password">Password: </label><input type="text" name="password"><br />
- <input type="submit" name="submit" value="Submit">
- </form>
- <div class="parent">
- <?php
- if(!empty($_COOKIE)) {
- echo $_COOKIE['username'];
- }
- else {
- echo '';
- }
- ?>
- </div>
- <style>
- .parent {
- background-color: red;
- width: 500px;
- height: 500px;
- text-align: center;
- line-height: 500px;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement