affiliate_link

Tuesday, October 25, 2011

Implementing Cookieless Session in ASP.NET

Cookies are basically text data which a web site may store of the user's machine. Cookies are not considered as safe medium to store data as they could be dangerous in some scenario. Also there might be the case that user has cookies turned off on his machine or the browser doesn't supports the cookies. Our application might get failed if it is depended on cookies support on client side. Most of the time session id is stored at client side in cookies. Therefore we won't be able to retrieve session's data in the case when cookies are not enable.

ASP.NET Cookieless Support


ASP.NET support cookieless execution of the application when the client doens't have cookies support. When to chose cookieless, the session id is transferred via the request url. Each and every request of the application page contains the session id embedded in its url. So the web application need not to request the session from the cookies.

To set Cookieless session in an ASP.NET application set following value in web.config file

<sessionstate cookieless="true" />

When you have cookieless session then the url may look like this

http://www.dailycoding.com/Posts/(_entv9gVODTzHuenph6KAlK07..)/test.aspx

Issue

Session IDs can be hijacked which is a security issue if above mentioned approach is used

Reference: http://www.dailycoding.com/Posts/implementing_cookieless_session_aspnet.aspx

Tuesday, September 13, 2011

How to find trigger assosiated with a table ?

select 'alter table '+quotename(s.name)+'.'+quotename(object_name(o.parent_obj))+ ' disable trigger '+quotename(o.name)
from sys.sql_modules m
join sys.sysobjects o on m.object_id=o.id
join sys.schemas s on s.schema_id = o.uid
where o.type='tr'
and definition like '%TABLENAME%'

Friday, August 19, 2011

Difference between varchar(max) and varchar(8000)

Varchar(8000) stores a maximum of 8000 characters

Varchar(max) stores a maximum of 2 147 483 647 characters

Works in SQL Server 2005 or above

Thursday, July 21, 2011

Zip Files or Folder On The Fly Using PHP

Zip Files
<?php
include_once 'CreateZipFile.inc.php';
$createZip = new CreateZipFile;
$createZip->addDirectory('/');
$filecontent1 = file_get_contents('fileone.txt');
$filecontent2 = file_get_contents('filetwo.txt');
$createZip->addFile($filecontent1, '/fileone.txt');
$createZip->addFile($filecontent2, '/filetwo.txt');
$zipFileName = 'myzip.zip';
$handle       = fopen($zipFileName, 'wb');
$out           = fwrite($handle, $createZip->getZippedFile());
fclose($handle);
$createZip->forceDownload($zipFileName);
@unlink($zipFileName);
?>
Zip Folder

<?php
include_once 'CreateZipFile.inc.php';
$createZip = new CreateZipFile;
$createZip->zipDirectory('/testdir', '');
$zipFileName = 'myzip.zip';
$handle       = fopen($zipFileName, 'wb');
$out           = fwrite($handle, $createZip->getZippedFile());
fclose($handle);
$createZip->forceDownload($zipFileName);
@unlink($zipFileName);
?>

Tuesday, July 5, 2011

Displaying iFrame content in a DIV

if your images are outside of your iFrame, of course your dropdown menu will not show up since you are trying to tell the dropdown menu to go out of its windows. iframe is a different window inside your html, therefore any overflow of the window will never go out, elements inside the iframe is not affected with the z-index.

what you could do is, if your http://website.com/dropdown.html has the dropdown content only, you can call it by jQuery

<div id="myDropDown">
</div>


<script type="text/javascript">
    $(document).ready(function() {
        $("#myDropDown").load("http://website.com/dropdown.html");
    });  
</script>

this will append the content of your dropdown.html into the div

Saturday, March 12, 2011

PHP function for checking http in a URL

function check_url($url)
{
    if(!strstr($url, "http://"))
    {
        $url = "http://".$url;
    }
    return $url;
}

Monday, February 7, 2011

Check website for http 404

function is_404($url) {
    $handle = curl_init($url);
    curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);

    /* Get the HTML or whatever is linked in $url. */
    $response = curl_exec($handle);

    /* Check for 404 (file not found). */
    $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    curl_close($handle);

    /* If the document has loaded successfully without any redirection or error */
    if ($httpCode >= 200 && $httpCode < 300) {
        return false;
    } else {
        return true;
    }
}