Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sessions - Please Help!

Featured Replies

I've been learning PHP and MYSQL for 2 months now. MYSQL is no problem - easy to learn and easy to program. PHP is harder to program than doing 150 push-ups in one second. Okay, maybe I'm over exaggerating, but it's hard. I'm getting use to the operators, booleans, and all that stuff, but what really bugs me are those sessions. I don't know how to use sessions properly. I'm trying to create a login and then view your personal profile, but it ain't happening - in my life anyway. Can someone please help me out?

Sessions are one of the easiest parts of PHP... e.g

 

<?php
//start the session
session_start();

//increment the 'hit' counter
$_SESSION['counter']++;

//display session vars
echo "You have been here " .$_SESSION['counter'] . " times this session.";

 

What specifically do you not understand about them? Post code if you already have something but are stuck on it.

  • Author

Sessions are one of the easiest parts of PHP... e.g

 

<?php
//start the session
session_start();

//increment the 'hit' counter
$_SESSION['counter']++;

//display session vars
echo "You have been here " .$_SESSION['counter'] . " times this session.";

 

What specifically do you not understand about them? Post code if you already have something but are stuck on it.

 

I'm trying to create a script when you log in, you can customize your profile and have your profile shown to the public.

I'm trying to create a script when you log in, you can customize your profile and have your profile shown to the public.

 

Perhaps you should practice simple counters like the above before jumping to the login, Heres what you have to face with a login system

 

- Protection against session hyjacking

- User Registration

- MYSQL Protection

 

Sessions are easy, Just imagen them as a database, to store a value:

 

$_SESSION['my_session'] = 'my_value';

 

To retrieve a value:

echo $_SESSION['my_session'];

 

Remember to use session_start() at the top of the page.

  • 2 weeks later...

Remember to include a test at the start of each script to make sure the user is logged in

 

Example, in myprofile.php

 

session_start();
if (!isset($_SESSION["userName"])){
	header( "Location: http://www.blahblag/login" );
}

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.