• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

PHP: How to solve ob_start() in combination imagepng() issue?

array_key_exists(): The first argument should be either a string or an integer

How to Install Composer Require doctrine/dbal

How to set dynamic `home` and `siteurl` in WordPress?

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

How can I make good efficent AJAX live forms with just jQuery and

How to create a scheduler application in php

laravel sanctum Route [login] not defined

Select option from dropdown menu with PHP and mySql

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

Stop caching for PHP 5.5.3 in MAMP

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

phpseclib 2.0 can not use Composer to create autoload

Explode not working properly with dash

Webscraping Symfony/Panther: Can't get HTML

About Contact Privacy policy Terms and conditions