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, 2020 in PHP by kartik
• 37,510 points
931 views

2 answers 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, 2020 by Niroj
• 82,880 points
0 votes
Hello, niroj.

Here is my idea

session_start(); $_SESSION['USERNAME']='Fahmida';

$_SESSION['PASSWORD']='Password';

unset($_SESSION['USERNAME']; unset($_SESSION['Password'];
answered Dec 7, 2020 by Famous
• 140 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, 2020 in PHP by Niroj
• 82,880 points
4,935 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, 2020 in PHP by Niroj
• 82,880 points
32,995 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, 2020 in PHP by Niroj
• 82,880 points
539 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, 2020 in PHP by Niroj
• 82,880 points
790 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, 2020 in Laravel by Niroj
• 82,880 points
21,895 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, 2020 in PHP by Niroj
• 82,880 points
6,834 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, 2020 in PHP by Niroj
• 82,880 points
2,813 views
0 votes
1 answer

How to clone a JavaScript object?

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

answered Apr 2, 2020 in Java-Script by Niroj
• 82,880 points
664 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, 2020 in PHP by Niroj
• 82,880 points
799 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, 2020 in PHP by Niroj
• 82,880 points
1,025 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP