Hello,
I am new to the whole PHP coding scene and am coding a gaming website for a team that I own. I am running into some troubles with the $_SESSION command. If you are logged in, you can view your profile and what not. The trouble comes in when you are able to edit other peoples profiles and there are no administration levels set yet. It seems that I need to save the session for a short amound of time ( preferrably until the user logs out ) but I have no idea where to look to find a simple, easy to learn tutorial on how to do so, and just call upon the SESSION name when needed. If someone could write a quick code with an explanation, I would be very appreciative or even to just post a link to an easy to read and understand tutorial.
Thanks,
- Jake
PHP Session Help
Moderator: General Moderators
When using sessions within PHP , always put:at the very top of your page, before any form of output is sent (this includes whitespace.)
session_start() will create a Session ID for you. It will also store the session ID in the users cookie for you.
If the user already has a valid session id in their cookie, it will automatically parse the session data into the $_SESSION superglobal for you.
Example:
page1.php
page2.php:
When the user clicks the link, it should output the value on page2.php 
Code: Select all
<?php
session_start();session_start() will create a Session ID for you. It will also store the session ID in the users cookie for you.
If the user already has a valid session id in their cookie, it will automatically parse the session data into the $_SESSION superglobal for you.
Example:
page1.php
Code: Select all
<?
session_start();
$_SESSION['myVar'] = 'boo!';
?>
<html>
<body>
<a href="page2.php">Click me!</a>
</body>
</html>Code: Select all
<?php
session_start();
echo $_SESSION['myVar'];
?>