<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Session Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/session/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/session/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 21 Feb 2026 07:13:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Understanding Sessions: Concepts, Architecture, Use Cases, and Implementation Guide</title>
		<link>https://www.scmgalaxy.com/tutorials/understanding-sessions-concepts-architecture-use-cases-and-implementation-guide/</link>
					<comments>https://www.scmgalaxy.com/tutorials/understanding-sessions-concepts-architecture-use-cases-and-implementation-guide/#respond</comments>
		
		<dc:creator><![CDATA[Vijay K]]></dc:creator>
		<pubDate>Tue, 27 May 2025 07:10:29 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BackendDevelopment]]></category>
		<category><![CDATA[ExpressJS]]></category>
		<category><![CDATA[FullStackDevelopment]]></category>
		<category><![CDATA[Management]]></category>
		<category><![CDATA[Redis]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Session]]></category>
		<category><![CDATA[StatefulApps]]></category>
		<category><![CDATA[UserAuthentication]]></category>
		<category><![CDATA[WebDevelopment]]></category>
		<category><![CDATA[WebSecurity]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=12420</guid>

					<description><![CDATA[<p>What is a Session? A session is a fundamental concept in computing, especially in web development, describing a semi-permanent exchange [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/understanding-sessions-concepts-architecture-use-cases-and-implementation-guide/">Understanding Sessions: Concepts, Architecture, Use Cases, and Implementation Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="683" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-102-1024x683.png" alt="" class="wp-image-12426" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-102-1024x683.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-102-300x200.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-102-768x512.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-102.png 1536w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h2 class="wp-block-heading">What is a Session?</h2>



<p class="wp-block-paragraph">A <strong>session</strong> is a fundamental concept in computing, especially in web development, describing a semi-permanent exchange of information between two communicating parties, typically a client (such as a browser) and a server. Due to the stateless nature of the HTTP protocol, sessions provide a mechanism to maintain continuity across multiple requests, enabling the server to remember users and their interactions over time.</p>



<p class="wp-block-paragraph">In practical terms, a session allows a web application to store user-specific information—such as login credentials, preferences, shopping carts, or form inputs—persistently during a user&#8217;s visit or even across multiple visits. Sessions bridge the gap between stateless HTTP transactions by creating a stateful experience, thus facilitating dynamic and personalized interactions.</p>



<h3 class="wp-block-heading">Key Characteristics of Sessions:</h3>



<ul class="wp-block-list">
<li><strong>Uniqueness:</strong> Each session is identified by a unique session ID.</li>



<li><strong>Persistence:</strong> Session data persists beyond a single request/response cycle.</li>



<li><strong>Timeout:</strong> Sessions expire after a period of inactivity or explicit termination.</li>



<li><strong>Security:</strong> Sessions must be managed securely to prevent unauthorized access.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h2 class="wp-block-heading">Major Use Cases of Sessions</h2>



<h3 class="wp-block-heading">1. User Authentication and Management</h3>



<p class="wp-block-paragraph">Sessions track authenticated users, allowing them to navigate a website without re-entering credentials on every page. After login, the session stores the user’s identity and permissions, enabling role-based access control.</p>



<h3 class="wp-block-heading">2. E-commerce Shopping Carts</h3>



<p class="wp-block-paragraph">Sessions maintain the state of a user’s shopping cart as they browse products, add or remove items, and proceed to checkout. This data persists even if the user navigates away from the cart page.</p>



<h3 class="wp-block-heading">3. Personalization and Preferences</h3>



<p class="wp-block-paragraph">Sessions store user settings like language, theme preferences, or last visited pages, delivering customized experiences.</p>



<h3 class="wp-block-heading">4. Multi-step Forms and Data Persistence</h3>



<p class="wp-block-paragraph">Web forms that span multiple pages rely on sessions to store user inputs temporarily until form completion, enhancing usability and preventing data loss.</p>



<h3 class="wp-block-heading">5. Security and Anti-CSRF Measures</h3>



<p class="wp-block-paragraph">Sessions help implement security tokens to prevent Cross-Site Request Forgery (CSRF) attacks and ensure requests originate from authenticated users.</p>



<h3 class="wp-block-heading">6. Resource Optimization and Rate Limiting</h3>



<p class="wp-block-paragraph">By tracking user activity within sessions, systems can manage resource usage, implement rate limits, or detect unusual patterns indicative of abuse.</p>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h2 class="wp-block-heading">How Sessions Work Along with Architecture</h2>



<h3 class="wp-block-heading">Core Components of Session Architecture</h3>



<ol class="wp-block-list">
<li><strong>Session Identifier (Session ID):</strong>
<ul class="wp-block-list">
<li>A unique, often cryptographically secure token generated by the server.</li>



<li>Sent to the client, typically stored in a cookie, URL parameter, or local storage.</li>



<li>Used to retrieve session data on subsequent requests.</li>
</ul>
</li>



<li><strong>Client-Side Storage:</strong>
<ul class="wp-block-list">
<li>The browser stores the session ID, commonly in a cookie (<code>HttpOnly</code> and <code>Secure</code> flags recommended).</li>



<li>The client includes this ID in HTTP requests, allowing the server to identify the session.</li>
</ul>
</li>



<li><strong>Server-Side Session Store:</strong>
<ul class="wp-block-list">
<li>Session data (user info, preferences) is stored server-side, linked to the session ID.</li>



<li>Storage options include:
<ul class="wp-block-list">
<li><strong>In-memory:</strong> Fast but non-persistent and limited to single-server scenarios.</li>



<li><strong>Database-backed:</strong> Persistent, suitable for distributed applications.</li>



<li><strong>Distributed caches:</strong> Redis or Memcached for scalable, fast session storage in clustered environments.</li>
</ul>
</li>
</ul>
</li>



<li><strong>Session Middleware and Management Layer:</strong>
<ul class="wp-block-list">
<li>Frameworks provide middleware to handle session creation, retrieval, update, and deletion.</li>



<li>Manages session lifecycle events, expiration, and security.</li>
</ul>
</li>
</ol>



<h3 class="wp-block-heading">Session Lifecycle Architecture</h3>



<ul class="wp-block-list">
<li><strong>Session Creation:</strong> Upon a user’s initial interaction or login, the server creates a session and generates a unique session ID.</li>



<li><strong>Session Persistence:</strong> The session ID is transmitted to the client, which stores it (usually in a cookie).</li>



<li><strong>Request Handling:</strong> Subsequent client requests include the session ID; the server retrieves session data using this ID.</li>



<li><strong>Session Updates:</strong> As the user interacts with the app, the server updates session data accordingly.</li>



<li><strong>Session Expiration:</strong> Sessions automatically expire after inactivity, or explicitly on logout, freeing server resources.</li>



<li><strong>Session Destruction:</strong> Session data is removed, and client cookies invalidated to end the session.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h2 class="wp-block-heading">Basic Workflow of Session Management</h2>



<ol class="wp-block-list">
<li><strong>Initialization:</strong> The server checks if a session ID exists in the incoming request.</li>



<li><strong>Session Validation:</strong> Validates the session ID and retrieves the associated session data.</li>



<li><strong>Session Usage:</strong> Uses session data to personalize responses or authorize access.</li>



<li><strong>Session Update:</strong> Updates session data if user interactions change state.</li>



<li><strong>Session Persistence:</strong> Saves updated session data back to storage.</li>



<li><strong>Session Termination:</strong> On logout or timeout, destroys the session and removes related cookies.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h2 class="wp-block-heading">Security Considerations in Session Management</h2>



<ul class="wp-block-list">
<li><strong>Secure Session IDs:</strong> Use long, random, cryptographically secure session IDs to prevent guessing attacks.</li>



<li><strong>HttpOnly Cookies:</strong> Prevent client-side JavaScript access to cookies, mitigating XSS attacks.</li>



<li><strong>Secure Flag:</strong> Ensure cookies are only sent over HTTPS to protect data in transit.</li>



<li><strong>SameSite Attribute:</strong> Mitigate CSRF by restricting cross-site cookie sending.</li>



<li><strong>Session Regeneration:</strong> Regenerate session IDs upon login to prevent session fixation.</li>



<li><strong>Timeouts:</strong> Implement reasonable inactivity timeouts to reduce risk exposure.</li>



<li><strong>Server-side Validation:</strong> Never trust client data; always validate session IDs and associated permissions on the server.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h2 class="wp-block-heading">Step-by-Step Getting Started Guide for Sessions</h2>



<h3 class="wp-block-heading">Step 1: Select a Development Platform</h3>



<p class="wp-block-paragraph">Choose a programming language and web framework supporting session management (e.g., Node.js with Express, Python with Django or Flask, Ruby on Rails, Java with Spring Boot).</p>



<h3 class="wp-block-heading">Step 2: Install and Configure Session Middleware</h3>



<p class="wp-block-paragraph">For example, in Node.js Express:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
const session = require(&#039;express-session&#039;);

app.use(session({
  secret: &#039;your-secret-key&#039;,  // Replace with a secure key
  resave: false,
  saveUninitialized: false,
  cookie: {
    secure: true,             // Use HTTPS in production
    httpOnly: true,
    maxAge: 30 * 60 * 1000   // Session expiration in milliseconds
  }
}));

</pre></div>


<h3 class="wp-block-heading">Step 3: Create Sessions on User Login</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
app.post(&#039;/login&#039;, (req, res) =&amp;gt; {
  // Authenticate user
  if (validUser) {
    req.session.user = { id: user.id, name: user.name };
    res.send(&#039;Login successful&#039;);
  } else {
    res.status(401).send(&#039;Unauthorized&#039;);
  }
});

</pre></div>


<h3 class="wp-block-heading">Step 4: Access Session Data in Protected Routes</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
app.get(&#039;/dashboard&#039;, (req, res) =&amp;gt; {
  if (req.session.user) {
    res.send(`Welcome back, ${req.session.user.name}`);
  } else {
    res.redirect(&#039;/login&#039;);
  }
});

</pre></div>


<h3 class="wp-block-heading">Step 5: Handle Session Logout and Destruction</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
app.post(&#039;/logout&#039;, (req, res) =&amp;gt; {
  req.session.destroy(err =&amp;gt; {
    if (err) return res.status(500).send(&#039;Logout failed&#039;);
    res.clearCookie(&#039;connect.sid&#039;);
    res.send(&#039;Logged out successfully&#039;);
  });
});

</pre></div>


<h3 class="wp-block-heading">Step 6: Implement Session Storage in Production</h3>



<p class="wp-block-paragraph">Use persistent or distributed session stores to handle scalability:</p>



<ul class="wp-block-list">
<li>Redis Store:</li>
</ul>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
const RedisStore = require(&#039;connect-redis&#039;)(session);
const redisClient = require(&#039;redis&#039;).createClient();

app.use(session({
  store: new RedisStore({ client: redisClient }),
  secret: &#039;your-secret-key&#039;,
  resave: false,
  saveUninitialized: false
}));

</pre></div>


<h3 class="wp-block-heading">Step 7: Monitor and Maintain Sessions</h3>



<p class="wp-block-paragraph">Regularly review session usage, perform load testing, and monitor for unusual activity to maintain session security and performance.</p>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">Sessions are a cornerstone of modern web applications, enabling stateful and personalized user experiences on a stateless protocol like HTTP. Understanding session architecture, use cases, workflows, and security best practices is critical for developers to build reliable, scalable, and secure applications. With the aid of mature frameworks and best practices, implementing robust session management is accessible and essential for every web project.</p>



<hr class="wp-block-separator has-alpha-channel-opacity">



<p class="wp-block-paragraph"></p>



<hr class="wp-block-separator has-alpha-channel-opacity">



<p class="wp-block-paragraph">If you want, I can provide detailed session implementation examples for other languages/frameworks or discuss advanced topics like token-based sessions or stateless authentication. Would you like that?</p>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/understanding-sessions-concepts-architecture-use-cases-and-implementation-guide/">Understanding Sessions: Concepts, Architecture, Use Cases, and Implementation Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/understanding-sessions-concepts-architecture-use-cases-and-implementation-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Super Global Variables in PHP</title>
		<link>https://www.scmgalaxy.com/tutorials/super-global-variables-in-php/</link>
					<comments>https://www.scmgalaxy.com/tutorials/super-global-variables-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Joydeep M]]></dc:creator>
		<pubDate>Wed, 24 Mar 2021 12:06:58 +0000</pubDate>
				<category><![CDATA[Programming Scripting Languages]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Post]]></category>
		<category><![CDATA[Request]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Session]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5747</guid>

					<description><![CDATA[<p>What is Super Global Variable? Super global variable is a variable which can be used in two different files for [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/super-global-variables-in-php/">Super Global Variables in PHP</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<ul class="wp-block-list"><li><strong>What is Super Global Variable?</strong></li></ul>



<p class="wp-block-paragraph">Super global variable is a variable which can be used in two different files for manipulation.</p>



<div class="wp-block-image is-style-default"><figure class="aligncenter size-large is-resized"><img decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Untitled.jpg" alt="" class="wp-image-5748" width="725" height="260" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Untitled.jpg 683w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Untitled-300x108.jpg 300w" sizes="(max-width: 725px) 100vw, 725px" /></figure></div>



<p class="wp-block-paragraph">For example we have a variable &#8220;<strong>a</strong>&#8221; in <strong>File1.php</strong> and we need to print, edit or any manipulation needed to be done in the variable in <strong>File2.php</strong> then we have to use <strong>Super Global Variable </strong>as a variable in <strong>File1.php</strong>.</p>



<ul class="wp-block-list"><li><strong>Types of Super Global Variable</strong> <strong>in PHP:-</strong></li></ul>



<p class="wp-block-paragraph">     &#8211; $_GET</p>



<p class="wp-block-paragraph">     &#8211; $_POST</p>



<p class="wp-block-paragraph">     &#8211; $_REQUEST</p>



<p class="wp-block-paragraph">     &#8211; $_COOKIE</p>



<p class="wp-block-paragraph">     &#8211; $_SESSION</p>



<p class="wp-block-paragraph">     &#8211; $_FILES</p>



<ul class="wp-block-list"><li>To see the u<strong>se of variable $_GET and $_POST</strong> follow the link given below:</li></ul>



<p class="wp-block-paragraph">/<a href="https://www.scmgalaxy.com/tutorials/_get-and-_post-variable-in-php/" data-type="URL" data-id="https://www.scmgalaxy.com/tutorials/_get-and-_post-variable-in-php/">https://www.scmgalaxy.com/tutorials/_get-and-_post-variable-in-php/</a></p>



<ul class="wp-block-list"><li><strong>Use of variable $_REQUEST</strong></li></ul>



<p class="wp-block-paragraph">&nbsp;<strong>$_REQUEST</strong>&nbsp;can catch the data which is sent using both <strong>POST </strong>&amp;&nbsp;<strong>GET</strong>&nbsp;methods whereas <strong>$_GET </strong>and <strong>$_POST </strong>can catch the data which is sent by get and post.</p>



<ul class="wp-block-list"><li><strong>Use of variable $_SERVER</strong></li></ul>



<p class="wp-block-paragraph">When we use $_SERVER we can extract extra data from the client when the form is filled. Extra data in a sense we can extract:</p>



<p class="wp-block-paragraph">     &#8211; HTTP Connection</p>



<p class="wp-block-paragraph">     &#8211; Server Information</p>



<p class="wp-block-paragraph">     &#8211; Host Information</p>



<p class="wp-block-paragraph">     &#8211; URL Information</p>



<p class="wp-block-paragraph">We can see it with the example given below:</p>



<script src="https://gist.github.com/Joydeep-cotocus/f7edd33ae6249bf13b9410a1e2c11690.js"></script>



<p class="wp-block-paragraph">Now when we insert the data in the form.html we will see the following information:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="546" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Capture-15-1024x546.jpg" alt="" class="wp-image-5754" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Capture-15-1024x546.jpg 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Capture-15-300x160.jpg 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Capture-15-768x409.jpg 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Capture-15.jpg 1366w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<ul class="wp-block-list"><li><strong>Use of $_COOKIE variable:</strong></li></ul>



<p class="wp-block-paragraph">Cookies are small file that the server embeds on the user&#8217;s computer each time the same computer requests a page with a browser it will send the cookie too. With PHP, we can both create and retrieve cookie values.</p>



<p class="wp-block-paragraph">To create a cookie we need to run the following command:</p>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">setcookie()</span></code></pre>



<p class="wp-block-paragraph"><strong>Syntax:</strong></p>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">setcookie(name, value, expire, path, domain, secure, httponly);</span></code></pre>



<p class="wp-block-paragraph">In the syntax only the name parameter is mandatory rest other parameters are optional.</p>



<p class="wp-block-paragraph">Example for creating a cookie:</p>



<script src="https://gist.github.com/Joydeep-cotocus/3cd00ee44b1dac2f1ceda0405a18979c.js"></script>



<ul class="wp-block-list"><li><strong>Use of $_SESSION variable</strong></li></ul>



<p class="wp-block-paragraph">For session variable refer the link given below:</p>



<p class="wp-block-paragraph"><blockquote class="wp-embedded-content" data-secret="xWUEbN9Xwv"><a href="https://www.scmgalaxy.com/tutorials/how-session-works-in-php/">How Session works in PHP</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;How Session works in PHP&#8221; &#8212; scmGalaxy" src="https://www.scmgalaxy.com/tutorials/how-session-works-in-php/embed/#?secret=eLUPc5cjtV#?secret=xWUEbN9Xwv" data-secret="xWUEbN9Xwv" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/super-global-variables-in-php/">Super Global Variables in PHP</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/super-global-variables-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How Session works in PHP</title>
		<link>https://www.scmgalaxy.com/tutorials/how-session-works-in-php/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-session-works-in-php/#comments</comments>
		
		<dc:creator><![CDATA[Joydeep M]]></dc:creator>
		<pubDate>Tue, 23 Mar 2021 07:30:33 +0000</pubDate>
				<category><![CDATA[Programming Scripting Languages]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Session]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5733</guid>

					<description><![CDATA[<p>Session is a way to store information (in variables) to be used across multiple pages. We can see the architecture [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-session-works-in-php/">How Session works in PHP</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Session is a way to store information (in variables) to be used across multiple pages. We can see the architecture of session workflow below:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="531" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session-1024x531.jpg" alt="" class="wp-image-5734" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session-1024x531.jpg 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session-300x156.jpg 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session-768x399.jpg 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session.jpg 1347w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<ul class="wp-block-list"><li>Initially we need to write the command session_start() to start a session.</li><li>Once we write the command server will check if there is a session available.</li></ul>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="541" height="262" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session_start.jpg" alt="" class="wp-image-5735" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session_start.jpg 541w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/session_start-300x145.jpg 300w" sizes="auto, (max-width: 541px) 100vw, 541px" /></figure></div>



<ul class="wp-block-list"><li>If there is no server then it will store a cookie in the client machine with the cookie name &#8211; <strong>PHPSESSID</strong> amd it will create a session id of 26 or 32 characters.</li><li>With that it will also store a file on server (Default Location &#8211; C:\xampp\tmp) with session id in the suffix.</li></ul>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="679" height="568" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/cookies.jpg" alt="" class="wp-image-5736" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/cookies.jpg 679w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/cookies-300x251.jpg 300w" sizes="auto, (max-width: 679px) 100vw, 679px" /></figure></div>



<ul class="wp-block-list"><li>If there is already a session in the client machine then it will show the variables stored in the session under (C:\xampp\tmp) the server.</li></ul>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="646" height="358" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Server.jpg" alt="" class="wp-image-5737" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Server.jpg 646w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Server-300x166.jpg 300w" sizes="auto, (max-width: 646px) 100vw, 646px" /></figure></div>



<ul class="wp-block-list"><li>Once we close the browser all the session ends.</li></ul>



<p class="wp-block-paragraph"><strong>Reference</strong>:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy"  id="_ytid_14454"  width="640" height="360"  data-origwidth="640" data-origheight="360" src="https://www.youtube.com/embed/9n7ZohSRKrQ?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;" class="__youtube_prefs__  epyt-is-override  no-lazyload" title="YouTube player"  allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen data-no-lazy="1" data-skipgform_ajax_framebjll=""></iframe>
</div></figure>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-session-works-in-php/">How Session works in PHP</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-session-works-in-php/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
