473,221 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

how to end up session

exoskeleton
104 100+
hi there im about to code for a log-out and i try to code this session_destroy();
but it wont work...the value of the variable stl there.

please tell me sir expert on how to design a log out and how to design a no-cache to prevent the user to click back button of the IE going to log in page again after he log in..

thank you please help
Oct 4 '06 #1
5 11729
exoskeleton
104 100+
in addtion : i got this message if i write session_destroy

Warning: Trying to destroy uninitialized session

hi there im about to code for a log-out and i try to code this session_destroy();
but it wont work...the value of the variable stl there.

please tell me sir expert on how to design a log out and how to design a no-cache to prevent the user to click back button of the IE going to log in page again after he log in..

thank you please help
Oct 4 '06 #2
ronverdonk
4,258 Expert 4TB
If you want to destroy the variable in the $_SESSION use
Expand|Select|Wrap|Line Numbers
  1. unset($_SESSION['var_name']);
If you want to destroy the entire session, use this code snippet from the PHP documentation http://nl3.php.net/manual/nl/functio...on-destroy.php
[PHP]<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}

// Finally, destroy the session.
session_destroy();
?> [/PHP]

Ronald :cool:
Oct 4 '06 #3
exoskeleton
104 100+
thank you sir...im very thankful for your brillian ideas...one more thing sir...ahmmm...if i declare the session is it automatic to create a cookie? coz in your sample given you also unset the cookie but i did not declare any cookie..

i know this is a newbie question ... hope you dont get ... you know.. im just a little confused little fellow coz i dont declare any cookie...

more power

If you want to destroy the variable in the $_SESSION use
Expand|Select|Wrap|Line Numbers
  1. unset($_SESSION['var_name']);
If you want to destroy the entire session, use this code snippet from the PHP documentation http://nl3.php.net/manual/nl/functio...on-destroy.php
[PHP]<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}

// Finally, destroy the session.
session_destroy();
?> [/PHP]

Ronald :cool:
Oct 5 '06 #4
ronverdonk
4,258 Expert 4TB
The code I posted is copied from the PHP documentation and serves as a sample. As you can see the code line
[PHP]if (isset($_COOKIE[session_name()])) {[/PHP]
will only delete the cookie if it is set. You can take that code line out or leave it just in case you ever decide to set session cookies.

Ronald :cool:
Oct 5 '06 #5
exoskeleton
104 100+
Thank you very much sir

The code I posted is copied from the PHP documentation and serves as a sample. As you can see the code line
[PHP]if (isset($_COOKIE[session_name()])) {[/PHP]
will only delete the cookie if it is set. You can take that code line out or leave it just in case you ever decide to set session cookies.

Ronald :cool:
Oct 13 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals...
1
by: mudge | last post by:
I'm running PHP Version 4.3.10. I'm trying to make it so that when a person logs in using a user name and password that their session is valid and continues for a few months so they don't have to...
6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
5
by: Abhilash.k.m | last post by:
This is regarding the session management using Out of proc session management(SQL SERVER). Among the samples below which one is better to set the session? 1. There are 20 session...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
14
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and...
7
by: aroraamit81 | last post by:
Well Guys, Here is a very strange trouble. When more than one users request tto same page at the same time then our session gets conflicted. Moreover I printed my SessionID, strangely but true I...
0
by: TRB_NV | last post by:
I'd been using an Access database based shopping cart, but wanted to change it so that it would use session variables. I have a form that's submitted to a page called addtocart.asp that contains...
1
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking...
5
by: lyealain | last post by:
<% If Session("username") = "" Then Response.Redirect("/CLS/Login.asp") End If Dim conn Dim connectstr Dim db_name, db_username, db_userpassword Dim db_server Dim res
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.