This repository has been archived by the owner on May 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
64 lines (54 loc) · 1.7 KB
/
index.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
// set up autoloading using composer
require 'vendor/autoload.php';
// create connection to memcached
$memcached = new Memcached();
$memcached->addServer('localhost', 11211);
// register handler (PHP 5.3 compatible)
$handler = new Lboy\Session\SaveHandler\Memcached($memcached);
session_set_save_handler(
array($handler, 'open'),
array($handler, 'close'),
array($handler, 'read'),
array($handler, 'write'),
array($handler, 'destroy'),
array($handler, 'gc')
);
// the following prevents unexpected effects when using objects as save handlers
register_shutdown_function('session_write_close');
session_start();
// start using the session
$_SESSION['user']['username'] = $_GET['username'];
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP-Node Demo</title>
<link href="components/bootstrap/docs/assets/css/bootstrap.css" rel="stylesheet" media="screen">
<script src="/components/jquery/jquery.js"></script>
<script src="/components/underscore/underscore.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
$(document).ready(function()
{
var socket = io.connect();
var template = _.template($('#js-news-template').html());
socket.on('news', function (news) {
var element = template({news: news});
$(element).hide().prependTo('#js-news-container').slideDown();
});
});
</script>
<script type="text/template" id="js-news-template">
<p class="well"><%- news %></p>
</script>
</head>
<body>
<div class="container">
<h1>Latest News</h1>
<div id="js-news-container"></div>
<h2>Session</h2>
<?php var_dump($_SESSION); ?>
</div>
</body>
</html>