Call me a noob. It's true.
How exactly does the session_start and other such functions work?I'm sure it's incredibly obvious, but I'm kinda strapped for time and resources.
![]()
Call me a noob. It's true.
How exactly does the session_start and other such functions work?I'm sure it's incredibly obvious, but I'm kinda strapped for time and resources.
![]()
you need to declare the session at the very top of your page before anything is parsed / the session variables used
Code:<?php session_start(); $_SESSION['user'] = $_SERVER['USER_AGENT']; ?>
Thanks, embarrassed.![]()
don't be... it wasnt too long ago that I had the very same question. thats the beauty of learning; we dont start with all the knowledge in the world![]()
session_start() must be called before anything else on the page (ie output). To continue the session (at least to be sure it continues) you must include session_start() on every related page on the site.
Once the session is enabled, $_SESSION[...] will be available on any page and data will be carried through continuously. It will expire after perhaps 15 minutes of inactivity, closing the browser, etc. A "session" describes it well.
To end a session, it's a bit harder-- look at session_destroy() and related functions on php.net.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Bookmarks