How can we create a session in PHP?

0 votes
I want to track each user whenever they logged in into my application. How can we track that?

Thank you!!
Mar 27 in PHP by kartik
• 35,500 points
100 views

1 answer to this question.

0 votes

Hello @kartik,

session_start() function is used in PHP to create a session.

Sample code:

session_start(); //Start session

$_SESSION['USERNAME']='Fahmida'; //Set a session value

unset($_SESSION['USERNAME']; //delete session value

The above code will enable to create session for each user that logged into your application

Thank you!!

answered Mar 27 by Niroj
• 76,940 points

Related Questions In PHP

0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

answered May 19 in PHP by Niroj
• 76,940 points
867 views
0 votes
1 answer

How to resolve the problem of losing a session after a redirect in PHP?

Hello @kartik, Carry out these usual checks: Make sure session_start(); is ...READ MORE

answered Aug 24 in PHP by Niroj
• 76,940 points
1,305 views
0 votes
1 answer

How can I declare a global variable in php?

Hello @kartik, The $GLOBALS array can be used instead: $GLOBALS['a'] = ...READ MORE

answered Oct 1 in PHP by Niroj
• 76,940 points
47 views
0 votes
1 answer

How can I get the classname from a static call in an extended PHP class?

Hello @kartik, __CLASS__ always returns the name of the ...READ MORE

answered Oct 27 in PHP by Niroj
• 76,940 points
30 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 76,940 points
3,470 views
0 votes
1 answer

What is type casting and type juggling in php?

Hey, The way by which PHP can assign ...READ MORE

answered Mar 27 in PHP by Niroj
• 76,940 points
549 views
0 votes
1 answer

What is the use of $_REQUEST variable in php?

Hii @kartik, The $_REQUEST variable is used to read the ...READ MORE

answered Mar 27 in PHP by Niroj
• 76,940 points
147 views
0 votes
1 answer

How to clone a JavaScript object?

Hello, You can clone an object and remove ...READ MORE

answered Apr 2 in Java-Script by Niroj
• 76,940 points
59 views
0 votes
1 answer

How can we track Google Analytics on a redirection page with PHP?

Hello @kartik, Since the page that is sending ...READ MORE

answered Apr 29 in PHP by Niroj
• 76,940 points
147 views
0 votes
1 answer

How can I expire a PHP session after 50 minutes?

Hii @kartik, Use the session_set_cookie_params funciton to set the session. If necessary call this function ...READ MORE

answered May 19 in PHP by Niroj
• 76,940 points
123 views