0

My first php file is basic.php

   <?php
       session_start();
   ?>

   <html>
       <body>
       <a href="basic2.php? name=qadeerhussain"> click on it</a>
           <?php 
               $_session['username']="qadeerhussain";
               print $_session['username'];
           ?>
       </body>
   </html>

Out put of basic.php is: click on it qadeerhussain my second basic2.php page is

   <?php
       session_start();
   ?>
   <html>
       <body>   
           <?php 
               print $_SESSION['username'];
           ?>
       </body>
   </html>

but it give me the following exception:

Notice: Undefined index: username in C:\wamp\www\test\basic2.php on line 12
1
  • 4
    PHP variables are case-sensitive: $_session is not $_SESSION. Commented Sep 15, 2013 at 12:53

3 Answers 3

1

Cause is upper case SESSION.. Not lowercase

Sign up to request clarification or add additional context in comments.

1 Comment

but now it give me the following exception:Notice: Undefined variable: _SESSION in C:\wamp\www\test\basic2.php on line 10
1

your session variable should be named $_SESSION not $_session

1 Comment

but now it give me the following exception:Notice: Undefined variable: _SESSION in C:\wamp\www\test\basic2.php on line 10
0

PHP variables are case-sensitive.So replace $_session to $_SESSION

1 Comment

but now it give me the following exception:Notice: Undefined variable: _SESSION in C:\wamp\www\test\basic2.php on line 10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.