创建会话 [英] Creating sessions
问题描述
我需要帮助在 php 中创建会话.我需要一个登录会话,然后如果用户想更改他们的用户名,他们可以.我知道如何更改用户名,但在使用会话时会有所不同.任何人都可以向我提供一些有关创建会话的示例或信息.更具体地说,我需要的会话.
I need help creating sessions in php. I need a session for login and then if the user wants to change their username they can but. I know how to change a username but it is different when using sessions. Can anyone provide me with some examples or information on creating sessions. More specifically sessions that I need.
哦,我差点忘了我在使用 mysql 和 php myadmin.我知道使用 mysqli 做事的新方法,但这纯粹是为了学习目的.
Oh I almost forgot I am using mysql and php myadmin. I am aware of the new ways of doing things with mysqli but this is purely for learning purposes.
推荐答案
<?php
session_start();
$_SESSION['username'] = 'Subie';
$username = $_SESSION['username']
?>
会话非常简单我相信在完成任何会话相关的事情之前您总是需要 session_start().
Session are pretty easy I believe you always need the session_start() before any session related things can be done.
一旦我设置了 $_SESSION['username'],我现在可以在用户可能访问的任何 php 脚本中调用它.
Once I set the $_SESSION['username'] I can now call it in any php script the user might visit.
这里有关于会话的很好的概述... http://www.w3schools.com/php/php_sessions.asp
Here's a good overview on sessions... http://www.w3schools.com/php/php_sessions.asp
这篇关于创建会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!