ad

Monday, July 8, 2024

PHP Session

php session


What is the PHP Session

PHP sessions enable you to save stateful information between page requests from the same user by storing user data on the server for later use. Sessions are frequently used for things like maintaining a user's login across several website pages without requiring a new authentication every time a page loads.

Sessions are essential to web development because they preserve stateful behavior in the stateless HTTP protocol. They let websites to retain user information and preferences, including as login status, contents of the shopping cart, and user data, across pages. A session ID, which is often sent between the client and server via URLs or stored in a cookie, is used to maintain sessions.

This data is safely stored in the server-side session storage, guaranteeing that only authorized users can access it and that neither other users nor outside threats may access it.

Information is briefly stored and sent across pages using PHP sessions (until the user closes the website).In order to retain and transfer cart information, such as username, product code, product name, and price, among other details, from one page to another, shopping websites frequently employ the PHP session approach.In order to identify the user and prevent conflicts across different browsers, PHP sessions generate distinct user IDs for each browser.

When users move between pages or take activities on the application, web applications frequently need to retain user-specific data. PHP sessions offer a workaround for this by enabling the temporary storing of data across several pages while a user is on the site. A distinct session ID is given to each visitor; this ID might be sent over the URL or kept in a cookie. By using this session ID, the server may obtain the relevant session data and provide users with individualized experiences. In order to provide dynamic and customized online experiences, sessions are necessary for storing user-specific data, monitoring preferences, and enabling login sessions.


1] PHP Session_start()

Start a PHP session: The first step is to start a session. Session variables can be created to store data after the session has started. PHP session_start() function is used to start a new session.

Syntax :- 

<?php 

session_start();

?>

Example :-

<html>

<body>

<?php

$_SESSION["user Name"]="seeta";

echo "Session Information set the successfully.";
?>
<a href="session2.php"> Next page visit</a>

<?php

session_start();

?>

</body>

</html>


Output 

2] PHP Access  Session

Next, create another page called “demo_session1.php”. This page accesses session information established on the first page (“demo_session2.php”). Session variables are not passed individually to each new page, but are retrieved from the session that opens at each page start (session_start()).


Syntax :- 

session_start();

<?php
session_start();


$username = $_SESSION['username'];{
$userId = $_SESSION['user_id'];}

echo "Welcome back, $username (ID: $userId)";
?>


3] PHP Session_destroy

PHP execution can be terminated using the session_destroy() function, which requires no parameters.

<?php

session_start();

if(isset($_SESSION["name"])){
unset($_SESSION["user_id]);}
}

session_destory();

?>

Related Post :-

Sunday, July 7, 2024

XAMPP Server process

1 Step :- 

Visual Studio Code  Install :-

        The use those laptops or computers first to download to the visual studio code
   You use those laptops or computers first to download to the Visual Studio Code Software this
 software is used to code the purpose of the project page
         

   1 Step : Download the software.
   
   2 Step : open the visual studio code.
   
   3  Step :  create New File

   4 Step  : Write/ Type Your Code.

  5 Step : Save Your File.

  6 Step : Run Your code. 

 2 Step :- 

X = Cross-Platform 
A = Apache Server
M = MariaDB
p = PHP
P = Perl

 


download  the XAMPP  

than install process receive warning massage such as Do you want to run this file?  click the YES  button to continue with installation process.

download process XAMPP


 3 Step :- 

  ஃ Next Step  Setup -XAMPP 

  à®ƒ   Welcome to the XAMPP Setup Wizard.
       
                  Click NEXT>  Button 

Click NEXT>  Button



 4 Step :- 

           1]  ALL components  are checked by default, 

           2]  No change anything and 

           3]  Click the NEXT Button 

Click the NEXT Button



       

     5 Step :-  

       1] Next Select a folder to  install XAMPP  
       2] C:/xampp in C drive   set and install ,
       3] Click NEXT> button.

Click NEXT> button.


     6 Step :-

   1] XAMPP  Setup ready to Installing  Computer.
   2] Click the NEXT Button 


Click the NEXT Button

   7  Step :-

           Click the FINISH  Button to  the Completing  process XAMPP Setup Wizard

Finish  Button



    8 Step :-

    1]  XAMPP Control Panel manually START and STOP  Apache And MySQL .
     2]  Start The Apache AND  MySQL


Start The Apache AND  MySQL

This Process is Complete  


Select a folder to XAMPP  

      1]   Than htdocs click.
 
     2]  Create  to The New Folder  (folder Name is :- E-Commerce Project ).
 
     3] This Folder  Save to all php program/code . 


Saturday, July 6, 2024

JavaScript Bitwise Operators

 

JavaScript Bitwise Operators

Bitwise Operators

1]  AND  ( & )

2] OR ( | )

3] NOT ( ~ )

4] XOR ( ^)

6] right shift ( >>)

5] left  shift ( << )

Example :-

Bitwise Operators Example :

Bitwise Operators


1]  AND  ( & )

Example :-


// Bitwise AND (&)
 let q = 5;
 let p = 3
 let resultAnd= q & p;
 console.log("q&p", resultAnd);

Output :-

Bitwise And


2] OR ( | )

Example :-


// Bitwise Or (|)  
 let q = 5;
 let p = 4;
 let resultor= q | p;
 console.log("q|p", resultor);

Output :-



3] NOT ( ~ )

Example :-

// Bitwise not (~ )
 let q = 4;
 
 let resultNotq= ~ q ;
 console.log("~q", resultNotq);
Output :-



4] XOR ( ^)

Example :-


let x=5;
let y=1;
let result = x ^ y;
console.log(result);

Output :-



6] right shift ( >>)

Example :-


let x=6;
let result =x<<1;
console.log(result);

Output :-



5] left  shift ( << )

Example :-


let x=2;
let result =x>>1;
console.log(result);

Output :-

JavaScript Logical Operators Explained with Examples

 


  Logical Operator

  1]  logical and (&&)

  2] logical or ( | | )

  3]  logical ( ! )

Logical Operator 

Example :-

Logical Operator

 Logical Operator

  1]  logical and (&&)

Example :-

//True and False value = False
 let s =true;
 let t=false;
  let result= s && t;
  console.log(result);

  // True and True value = True
  let u = true;
  let v= true;
  let result1= u&&v;
  console.log(result1);
  //False and True value = False
  let w=false;
  let x=true;
  let result2= w && x;
  console.log(result2);

  //False and False value = False
  let y=false;
  let z=false;
  let result3=y &&z;
  console.log(result3);

Output:-

logical and (&&)


  2] logical or ( | | ) 

Example :-

//True and False value = True
 let s =true;
 let t=false;
  let result= s || t;
  console.log(result);

  // True and True value = True
  let u = true;
  let v= true;
  let result1= u||v;
  console.log(result1);
  //False and True value = True
  let w=false;
  let x=true;
  let result2= w || x;
  console.log(result2);

  //False and False value = False
  let y=false;
  let z=false;
  let result3=y ||z;
  console.log(result3);

Output:-

logical or ( | | )


  3]  logical ( ! )

Example :-


// value not true = false
let q=true;
let result =!q;
console.log(result);
// value not false = true
 let a= false;
 let result2=!a;
 console.log(result2);

Output:-



Related Post:-

php program to print alphabet pattern G

php program check to even or odd number

css element selector

JavaScript Comparison Operators

 


 Comparison Operators   

    1] Equal  to  (==)

   2]  Equal value and equal type (= = =)

   3] Not equal (! =)

   4] Not equal value or not equal type (! = =)

   5] Greater than ( > )

   6] less than (< )

   7] Greater than or equal to (> = )

   8] less than or equal to (< =)

 Example :-

Comparison Operators

   1] Equal  to  (==)

 Check the two  value  equal or not 

Answer is True or False

Two value is equal  is = True

 Two value is not  equal is = False

Example :-


var a=2;
var b=2;
console.log(a==b);

Output:-



   2]  Equal value and equal type (= = =)

       Check two values are equal and of the same .

       Two value is equal  is = True

       Two value is not  equal is = False

Example :-

var a=7;
var b="7";
console.log(a===b);
Output:-



   3] Not equal (! =)

Check  two values are not equal 
 than Answer is  True

Example :-


var z=7;
var  y=5;
console.log(z!=y);

Output:-



   4] Not equal value or not equal type (! = =)

Example :-


var z=7;
var  y="7";
console.log(z!==y);

Output:-



   5] Greater than ( > )

Example :-

var z=7;
var  y=5;
console.log(z>y);



Output:-



   6] less than (< )

Example :-


var z=7;
var  y=5;
console.log(z<y);

Output:-



   7] Greater than or equal to (> = )

Example :-


var z=7;
var  y=5;
console.log(z>=y);

Output:-



   8] less than or equal to (< =)

Example :-


var z=7;
var  y=5;
console.log(z<=y);

Output:-