Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:46:12+00:00 2026-06-14T05:46:12+00:00

Basically what the title says. I know how to make a normal variable into

  • 0

Basically what the title says. I know how to make a normal variable into a session variable ($_SESSION['var']), but not when it contains another var

This is my code:

<?php
session_start();

$_SESSION["uname"] = "Tyler";

if (isset($_SESSION["coins{$uname}"])) 
{
    echo "$_SESSION["uname"] : $_SESSION["coins{$uname}"]";
}
elseif ($_SESSION["uname"] == "LOut")
{
    $_SESSION["coins{$uname}"] = "0";
    echo "Log In";
}
else
{
    $_SESSION["coins{$uname}"] = 500;
    echo "$_SESSION["uname"] : $_SESSION["coins{$uname}"]";
}
?>

I’ve tried the following:

$_SESSION['{coins.$uname}']
$_SESSION['coins.$uname']
$_SESSION['coins.$_SESSION['uname']']

And I don’t remember if I’ve tried anything else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:46:14+00:00Added an answer on June 14, 2026 at 5:46 am

    You say that it’s not working, but you haven’t specified if setting it or echoing it is the problem: Based on your original, unedited question, there are two problems:

    Setting the session variable

    This should work:

    $_SESSION["coins{$uname}"] = 500;
    

    If you can’t get it to work, try breaking it down into a couple of steps.

    $tempname = 'coins'.$uname;
    $_SESSION[$tempname] = 500;
    

    Now test it.

    Outputting the session variable

    echo $_SESSION["coins{$uname}"]; or echo $_SESSION[$tempname];

    Edit

    There is a syntax error in your code:

    echo "$_SESSION["uname"] : $_SESSION["coins{$uname}"]";
    

    You are closing your starting quote (“) by mistake when you try to open quotes for [“uname”]. Try:

    echo "$_SESSION['uname'] : ".$_SESSION["coins{$uname}"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

...basically exactly what the title says. NetworkStream.Length is not implemented. What's an alternative? I'm
The title pretty much says it all, but basically I have a main parent
Sorry for the confusing title, but it basically says it all. Here's the structures
The title already says a lot, but basically what i want to do is
Title basically says it all. I've tried Googling but return a load of false
As the title says, is there another way to pass a variable from "current"
Basically, the title says everything. The numbers are not too big (the maximum for
Basically what the title says, I want to get the URL and HTTP Verb
Basically what the title says. I created a new MVC application. I'm trying to
so basically like the title says is there a way to use NSSortDescriptor to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.