Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Photogram project PHP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raghav
Photogram project PHP
Commits
c0097c38
Commit
c0097c38
authored
1 week ago
by
Raghav
Browse files
Options
Downloads
Patches
Plain Diff
Session class created
parent
22cb2d27
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_includes/Session.class.php
+51
-0
51 additions, 0 deletions
_includes/Session.class.php
sessiontest.php
+9
-0
9 additions, 0 deletions
sessiontest.php
with
60 additions
and
0 deletions
_includes/Session.class.php
0 → 100644
+
51
−
0
View file @
c0097c38
<?php
class
Session
{
// To start the session
public
static
function
start
()
{
session_start
();
}
// To unset the session variables (delete the session variables)
public
static
function
unset_all
()
{
session_unset
();
}
// To destroy the session(delete the session files)
public
static
function
destroy
()
{
session_destroy
();
}
// To set the key and values in $session array
public
static
function
set
(
$key
,
$value
)
{
$_SESSION
[
$key
]
=
$value
;
}
// To delete the required key values
public
static
function
del
(
$key
)
{
unset
(
$_SESSION
[
$key
]);
}
// To check the given key is present
public
static
function
isset
(
$key
)
{
return
isset
(
$_SESSION
[
$key
]);
}
// To get the key value
public
static
function
get
(
$key
,
$default
=
false
)
{
if
(
Session
::
isset
(
$key
)){
return
$_SESSION
[
$key
];
}
else
{
return
$default
;
}
}
}
This diff is collapsed.
Click to expand it.
s
g
.php
→
s
essiontest
.php
+
9
−
0
View file @
c0097c38
...
...
@@ -6,12 +6,21 @@ session_start();
print
(
"_SESSION
\n
"
);
print_r
(
$_SESSION
);
print
(
"Session ID = "
.
session_id
()
.
"
\n
"
);
// To Clear the values in session array but not delete.
if
(
isset
(
$_GET
[
'clear'
]))
{
printf
(
"Clearing....
\n
"
);
session_unset
();
print
(
"Session ID[unset] = "
.
session_id
()
.
"
\n
"
);
}
// To destroy the session
if
(
isset
(
$_GET
[
'destroy'
]))
{
printf
(
"Destroying..
\n
"
);
session_destroy
();
print
(
"Session ID[destroyed] = "
.
session_id
()
.
"
\n
"
);
}
/*
* We can assignment $_SESSION['A'];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment