GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — session/example.php at master · stackphp/session
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Expand file tree/ Copy pathexample.phpMore file actions 44 lines (31 loc) · 1.18 KB / Copy pathexample.phpFile metadata and controls44 lines (31 loc) · 1.18 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 <?php use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; require 'vendor/autoload.php'; $app = new Silex\Application(); $app->get('/login', function (Request $request) { $session = $request->getSession(); $username = $request->server->get('PHP_AUTH_USER'); $password = $request->server->get('PHP_AUTH_PW'); if ('igor' === $username && 'password' === $password) { $session->set('user', array('username' => $username)); return new RedirectResponse('/account'); } return new Response('Please sign in.', 401, [ 'WWW-Authenticate' => sprintf('Basic realm="%s"', 'site_login'), ]); }); $app->get('/account', function (Request $request) { $session = $request->getSession(); if (null === $user = $session->get('user')) { return new RedirectResponse('/login'); } return sprintf('Welcome %s!', $user['username']); }); $stack = (new Stack\Builder()) ->push('Stack\Session'); $app = $stack->resolve($app); $request = Request::createFromGlobals(); $response = $app->handle($request)->send(); $app->terminate($request, $response); |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |